Warning messages after installing Nextcloud server

In a previous post, we installed Nextcloud on Ubuntu Server 16.04 LTS. All good, but once we go to User  – Settings – Basic Settings we see several messages written in red, telling us we need to perform additional tasks.

Now, Nextcloud will work without those corrections, but if we want maximum responsiveness from our server, it’s better to take care of them. Let’s start with the first one:

Your data directory and your files are probably accessible from the internet. Your .htaccess files is not working.

Log in to the server and make a small change in the apache2.conf file:

sudo nano /etc/apache2/apache2.conf

Look for those lines:

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted

Replace None with All. Then save and close the file and restart the apache service:

sudo service apache2 restart

The first warning message is gone. We are going to ignore the second message (Accessing site insecurely via HTTP), since our server is not public and it doesn’t have a domain name, so it doesn’t need and can’t have an SSL certificate.

No memory cache has been configured. To enhance performance, please configure a memcache

We start by installing APCu and Redis to enable caching. That will make our server faster when displaying media files and generating thumbnails:

sudo apt-get install php-apcu redis-server php-redis
sudo nano /etc/redis/redis.conf

In the file, make the following changes:

  • port 6379 to port 0
  • uncomment the line:   unixsocket /var/run/redis/redis.sock
  • uncomment the line:   unixsocketperm 700
  • on the same line, change 700 to 770

Save and close the file, then add the apache user www-data to the redis group, then restart apache service and start the redis service:

sudo usermod -a -G redis www-data
sudo service apache2 restart
sudo service redis-server start
sudo systemctl enable redis-server

Next, we open the Nextcloud configuration file:

sudo nano /var/www/html/nextcloud/config/config.php

Add the following block of code at the end of the file, BEFORE the last closing bracket:

‘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,

Reboot the server for the configuration to take effect.

The PHP OPcache is not properly configured

Open the php.ini configuration file:

sudo nano /etc/php/7.0/apache2/php.ini

Find each one of the following lines, un-comment them and change the settings according to the indications in the warning message. (The Ctr-W combination in the nano editor will help with the search):


There is one more consideration. The maximum file size for uploads is set to 2 MB, which is way too small for a photo or a video. So let’s change that to something bigger, like 1 GB or more. In the same file, find and change those two lines:

upload_max_filesize = 1024M
post_max_size = 1050M

We put the second value a little big bigger, to avoid errors when uploading a file that is EXACTLY 1 GB in size.

One more apache2 restart and we’re done.


Install Nextcloud on Ubuntu 16

In this post, we will setup a server and install Nextcloud on it. My distribution of choice is Ubuntu Server, version 16.04 LTS. I happen to like the non-GUI interface, so everything will be done in the terminal. I will make this as short as possible. Let’s start!

The server has 1 virtual processor and 1 GB of memory. More than enough for a home test server running Nextcloud. Use the default settings during install. At the end, when asked about packages to add, choose these three: LAMP server, Standard system utilities and OpenSSH server.

When asked, set a password for MySQL root user and remember it.

After installation, update the server:

sudo apt update
sudo apt upgrade

There is a good idea to set up a static IP for the server. Open and edit this file:

sudo nano /etc/network/interfaces

Replace this:

iface [your adapter name] inet dhcp

with this:

iface [your adapter name] inet static
address (or whatever IP you wish to assign to it)
gateway (the address of your router)

Save and close the file with Ctrl-O and Ctrl-X. Reboot the server to reflect the changes.

Next, we are going to create a MySQL database for Nextcloud:

sudo mysql -u root -p
create database nextcloud;
GRANT ALL ON nextcloud.* TO ‘nextclouduser’@’localhost’ IDENTIFIED BY ‘password’;
flush privileges;

Choose your own database name, user and password. We will need them later.
A good practice is to secure the mysql installation. Run this command:

sudo mysql_secure_installation

Answer no the the first two questions and yes to the rest.

Next, we need to install a set of php modules needed by Nextcloud:

sudo apt-get install php-gd php-json php-curl php-mbstring
sudo apt-get install php-intl php-mcrypt php-imagick php-xml php-zip

Also, enable two additional Apache mods and restart Apache to make them available:

sudo a2enmod rewrite headers

sudo service apache2 restart

We are ready now to download and install Nextcloud. We will use the following commands:

cd /var/www/html
sudo wget https://download.nextcloud.com/server/releases/latest-13.tar.bz2
sudo tar -jxvf latest-13.tar.bz2
sudo chown -R www-data:www-data /var/www/html/nextcloud
sudo rm latest-13.tar.bz2

All done in the command line. Reboot the server and then open the IP address in a browser, like this:  (or whatever IP you assigned to it earlier)

You will see the initial configuration for Nextcloud.

Create a user and a password in the first window and enter the database details in the second one. Leave the Data folder as is. Click on Finish setup.

The basic installation is ready. But, additional steps are needed to make the best of our Nextcloud server. Check my other post: Warning messages after installing Nextcloud server