Note: Redis cache is optional. You can safely skip this part.

If you go to your OwnCloud admin page, you might see the following warning:

No memory cache has been configured. To enhance your performance please configure a memcache if available.

We will enable memory caching for nextCloud by using Redis. Install Redis server from Ubuntu 16.04 repository.

sudo apt install redis-server

You can check the version with:

redis-server -v

Sample output:

Redis server v=3.0.6 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=687a2a319020fa42

Now we can check if redis server is running.

systemctl status redis

 

From the above screenshot, we can see that it’s running and auto-start is enabled. If for any reason it’s not running, execute the following command:

sudo systemctl start redis-server

And if auto-start at boot time is not enabled, you can use the following command to enable it:

sudo systemctl enable redis-server

Now let’s configure Redis as a cache for nextCloud. Install the PHP extension for interfacing with Redis.

sudo apt install php-redis

Check if the extension is enabled or not.

php --ri redis

 

We can see that Redis extension is enabled and the version is 2.2.8 which is higher than the required 2.2.5+ by nextCloud. You may need to manually enable Redis extension either by restarting Apache

sudo systemctl restart apache2

or by running the following commmand:

sudo phpenmod redis

Next, edit OwnCloud configuration file.

sudo nano /var/www/owncloud/config/config.php

Add the following lines above the ); line.

'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.local' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => array(
     'host' => 'localhost',
     'port' => 6379,
     ),

ubuntu 16.04 redis cache nextcloud

Save and close the file. Now go to nextCloud admin page again, the warning about memory caching should be gone.

Congrats! You have successfully set up NextCloud personal cloud storage on a Ubuntu 16.04 VPS with Apache, MariaDB and PHP7.