Installing Nextcloud
Download Nextcloud Zip file.
wget https://download.nextcloud.com/server/releases/latest.zip
Unzip Nextcloud Zip file.
unzip latest.zip
Move Nextcloud folder to Apache web server directory. (Folder name can be changed to something different at this point if desired.)
sudo mv nextcloud /var/www/
Set nextcloud folder user permission to the www-data user. (If you change the name of the nextcloud folder, substitute it in the below command.)
sudo chown www-data:www-data -R /var/www/nextcloud
Create Nextcloud Apache configuration file. (File name can be anything you want. If you’re planning to host more than one Nextcloud instance, name them something to associate it with each instance.)
sudo nano /etc/apache2/sites-available/nextcloud.conf
Add the below code to the newly created configuration file. Replace nextcloud in the below with the name that you gave to your Nextcloud folder if you changed it. Insert your server’s IP address or your desire URL for use with Nextcloud inplace of [Nextcloud URL] (removing the open and closed brackets).
<VirtualHost *:80>
DocumentRoot "/var/www/nextcloud"
ServerName [Nextcloud URL]
<Directory "/var/www/nextcloud/">
Options MultiViews FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
TransferLog /var/log/apache2/nextcloud_access.log
ErrorLog /var/log/apache2/nextcloud_error.log
</VirtualHost>
Enable Nextcloud’s Apache confirguation file.
sudo a2ensite nextcloud.conf
Restart Apache.
sudo systemctl restart apache2
Troubleshooting Nextcloud
Installing Redis.
sudo apt install redis php-redis
Open Nextcloud PHP configuration file. (Replace nextcloud with the name that you gave your Nextcloud directory.)
sudo nano /var/www/nextcloud/config/config.php
Add the following code to the PHP file right below ‘installed’ => true, .
(Note: There are two (2) spaces at the beginning of each line.)
'default_phone_region' => 'US',
'default_locale' => 'en_US',
'maintenance_window_start' => 1,
'memcache.local' => '\\OC\\Memcache\\APCu',
'distributed' => '\\OC\\Memcache\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' => array(
'host' => 'localhost',
'port' => 6379,
'timeout' => 0.0,
),
'maintenace' => false
Add user www-data to the redis group.
sudo usermod -aG redis www-data
Set Nextcloud’s PHP configuration file permissions. (Replace nextcloud with the name that you gave your Nextcloud directory.)
sudo chmod 660 /var/www/nextcloud/config/config.php
Install libmagickcore.
sudo apt install libmagickcore-6.q16-6-extra
sudo apt-get update && apt-get install redis
Open Nextcloud’s Apache SSL configuration file.
sudo nano /etc/apache2/sites-available/nextcloud-le-ssl.conf
Add the following code below Server Name to fix Strict Transport Security error.
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
Restart Apache.
sudo systemctl restart apache2
Open Crontab file for www-data user.
sudo crontab -u www-data -e
Add the follow code at the bottom of document to fix cron job error.
*/5 * * * * /usr/bin/php8.3 -f /var/www/nextcloud/cron.php
Open PHP’s apcu.ini file.
sudo nano /etc/php/8.3/mods-available/apcu.ini
Add the following at the bottom of document.
apc.enable_cli=1
Install missing indices.
sudo -u www-data php /var/www/nextcloud/occ db:add-missing-indices
sudo -u www-data php /var/www/nextcloud/occ maintenance:repair --include-expensive