If you go to your NextCloud settings -> overview 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. Run the following command to install Redis server from Ubuntu repository.
sudo apt install redis-server
You can check the version with:
redis-server -v
Sample output:
Redis server v=5.0.7 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=636cde3b5c7a3923
Now we can check if redis server is running.
systemctl status redis
Hint: If the above command didn’t quit immediately, you can press the Q key to gain back control of the terminal.
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
In order to configure Redis as a cache for nextCloud, we need to install the PHP extension for interfacing with Redis.
sudo apt install php-redis
Check if the extension is enabled.
php --ri redis
We can see that Redis extension is enabled. If it’s not enabled, run the following command:
sudo phpenmod redis
You may also need to reload Apache if the redis extension is still not enabled.
sudo systemctl reload apache2
Next, edit nextCloud configuration file.
sudo nano /var/www/nextcloud/config/config.php
Add the following lines above the ending );
line.
'memcache.distributed' => '\OC\Memcache\Redis', 'memcache.local' => '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => 'localhost', 'port' => 6379, ),
Save and close the file. Then restart Apache and PHP-FPM.
sudo systemctl restart apache2 php7.4-fpm
Now go to NextCloud settings -> overview page again and refresh the web page, the warning about memory caching should be gone.