sudo apt update && sudo apt upgrade -y
Official docs recommend installing all required PHP extensions.
sudo apt install apache2 mariadb-server libapache2-mod-php \
php-gd php-mysql php-curl php-mbstring php-intl php-gmp \
php-xml php-imagick php-zip php-bz2 php-fpm php-cli -y
Enable Apache modules:
sudo a2enmod rewrite headers env dir mime ssl
sudo systemctl restart apache2
Enter MariaDB:
sudo mysql
Run:
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'StrongPassword';
CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
FLUSH PRIVILEGES;
QUIT;
(These steps match official documentation.) Nextcloud
Get the latest version:
cd /tmp
wget https://download.nextcloud.com/server/releases/latest.tar.bz2
tar -xjf latest.tar.bz2
Move it to the web directory:
sudo mv nextcloud /var/www/
sudo chown -R www-data:www-data /var/www/nextcloud
sudo chmod -R 755 /var/www/nextcloud
sudo nano /etc/apache2/sites-available/nextcloud.conf
Paste:
<VirtualHost *:80>
ServerName cloud.example.com
DocumentRoot /var/www/nextcloud/
<Directory /var/www/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
</Directory>
ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
</VirtualHost>
Enable site:
sudo a2ensite nextcloud.conf
sudo systemctl reload apache2
sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache -d cloud.example.com
sudo -u www-data crontab -e
Add:
*/5 * * * * php -f /var/www/nextcloud/cron.php
Redis improves performance significantly.
This is recommended in modern Nextcloud guides. YouStable
Install Redis:
sudo apt install redis-server php-redis -y
sudo systemctl enable redis-server --now
Edit config:
sudo nano /var/www/nextcloud/config/config.php
Add:
'memcache.local' => '\\OC\\Memcache\\APCu',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' => [
'host' => 'localhost',
'port' => 6379,
],
Open browser:
http://cloud.example.com
Enter:
Nextcloud will auto‑create tables. Nextcloud