Warning
This article is old, and some of the information may be outdated or no longer valid.
If you have any questions or need to confirm any details, we recommend contacting our support team for up-to-date information and personalized assistance.
In this tutorial, we will explain how to install NextCloud with a Let´s Encrypt certificate and the Redis server on Debian 9 Stretch.
To set this up, you must have installed and configured LAMP. We also recommend creating the DNS record for the subdomain.
Installing Redis and Apache
Install the Redis package
# apt install php-redis redis-serverAnd enable it with
# systemctl enable redis-serverAlso install the PHP packages required for Nextcloud.
# apt install php7.0-zip php-dompdf php7.0-xml php7.0-mbstring php7.0-curl unzip php7.0-gd php7.0-mysqlTo enable the modules in Apache
# a2enmod rewrite headers env dir mimeAs instructed when the module installation finishes, restart Apache
# systemctl restart apache2Next, create a VirtualHost for NextCloud to start configuring Apache
# cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/nextcloud.confEdit the contents of the file
# nano /etc/apache2/sites-available/nextcloud.confWith the following content
<VirtualHost *:80>
ServerName nc.diariodeunalinuxera.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/vhost/nc.diariodeunalinuxera.com/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/html/vhost/nc.diariodeunalinuxera.com/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo
#AuthConfig
Order allow,deny
allow from all
</Directory>
ErrorLog /var/www/html/vhost/nc.diariodeunalinuxera.com/logs/error.log
LogLevel warn
CustomLog /var/www/html/vhost/nc.diariodeunalinuxera.com/logs/access.log combined
<IfModule mod_headers.c>
Header always set Strict-Transport-Security: "max-age=31536000; includeSubdomains; preload"
</IfModule>
</VirtualHost>Enable the website and restart Apache
# cd /etc/apache2/sites-available/
# a2ensite nextcloud.conf
# systemctl restart apache2Installing the SSL certificate
Now install the packages required for the SSL certificate
# apt install letsencrypt certbot python-certbot-apacheCreate the certificate with the following command; you must enter a valid email address. When the configuration files and other important items, such as the CSR, are generated, you must choose the type of HTTPS access to use. The recommended choice is option 2, “Secure – Make all requests redirect to secure HTTPS access”
# certbot --authenticator standalone --installer apache -d nc.diariodeunalinuxera.com --pre-hook "systemctl stop apache2" --post-hook "systemctl start apache2"Installing NextCloud
The web server now has a vHost that allows access through a subdomain. The next step is to install NextCloud. To do this, download the latest version to the website directory and create its database.
# cd /var/www/html/vhost/nc.diariodeunalinuxera.com/www/
# wget https://download.nextcloud.com/server/releases/latest.zipExtract the latest.zip file with
# unzip latest.zipMove the extracted files and remove the directory with
# mv nextcloud/* . && mv nextcloud/.* . && rm -rf nextcloudChange the permissions
# chown -R www-data:www-data .*And then create the database
# mysql -u root -pCREATE DATABASE nextcloud;
CREATE USER ‘ncuser’@’localhost’ IDENTIFIED BY ‘ncpassword’;
GRANT ALL PRIVILEGES ON nextcloud . * TO ‘ncuser’@’localhost’;Proceed with the NextCloud installation by entering the URL in your browser. Start by setting up an administrator account with a strong password and the storage path for data uploaded to the cloud. For security, we recommend placing this path outside the website directory. You can do this by creating a user with a directory inside their home directory.
# useradd -m -d /bin/nologin ddulcomCreate the directory and change the permissions with
# mkdir -p /home/ddulcom/cloud
# chown www-data:ddulcom -R /home/ddulcomThis configuration causes errors in the .htaccess file, so you must add the configuration available at the following link
https://gitlab.com/snippets/1723283
Once this part is complete, configure the database by entering the user details and the name of the database created earlier in MariaDB (user ncuser and database nextcloud in this example). Finally, click Completar la instalación.
Create the administrator account and set the corresponding path.
And complete the installation.
If there have been no problems, you will see a screen like this and be in the NextCloud dashboard.
You now have a working cloud. Finally, configure caching in Redis by editing the file
# nano /etc/redis/redis.confModify the following parameters
Change
port 6379 a port 0Uncomment
unixsocket /var/run/redis/redis.sockUncomment
unixsocketperm 700and change it to 770.
Add the Redis user to the Apache group
# usermod -a -G redis www-dataAnd restart Redis and Apache
# systemctl restart redis-server
# systemctl restart apache2To make NextCloud use Redis, modify the configuration file
# nano /var/www/html/vhost/nc.diariodeunalinuxera.com/www/config/config.phpBy adding the following settings:
'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'redis' =>;
array (
'host' =>; '/var/run/redis/redis.sock',
'port' =>; 0,
'timeout' =>; 0.0,
),Restart the server to apply the new configuration and add the additional settings required for PHP Opcache to php.ini
# nano /etc/php/7.0/apache2/php.iniBy adding the following configuration:
Nextcloud Opcache settings opcache.enable=1 opcache.enable_cli=1 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=10000 opcache.memory_consumption=128 opcache.save_comments=1 opcache.revalidate_freq=1Save and restart Apache
# systemctl restart apache2That’s it! NextCloud is now running correctly with Let’s Encrypt and Redis.
This tutorial was written by Jessica Suárez of diariodeunalinuxera.com