Configuring Memory Caching In Nextcloud
1. Install APCu and Redis:
$ sudo apt install php-apcu redis-server php-redis
$ sudo service apache2 restart2. Edit the configuration file
$ sudo nano /etc/redis/redis.confCtrl+w and enter “port” to search for and change:
port 6379to
port 0Then Ctrl+w to search for and uncomment:
unixsocket /var/run/redis/redis.sockand uncomment the line below and change the permissions to 770:
unixsocketperm 700to
unixsocketperm 770Ctrl+x, the ‘Y’ to save and exit.
3. Add the Redis user redis to the www-data group:
$ sudo usermod -a -G redis www-data4. Restart Apache:
$ sudo service apache2 restart5. Start Redis server:
$ sudo service redis-server start6. Add the caching configuration to the Nextcloud config file:
$ sudo nano /var/www/html/nextcloud/config/config.phpAdd the following right after the last line and before the ‘);’ (before the last parenthesis and semicolon)
'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\OC\Memcache\Memcached',
'redis' =>
array (
'host' => 'localhost',
'port' => 0,
'timeout' => 0.0,
),Ctrl+x, then ‘Y’ to save and exit.
NOTE: If you are getting and Internal Server Error with the config above, please see the UPDATED comments below – https://kenfavors.com/code/configuring-memory-caching-in-nextcloud/#comment-8355
To verify Redis is enabled to start on boot:
$ sudo systemctl enable redis-serverNow when you go to the admin page in Nextcloud, there should no longer be a ‘Security & Setup Warning’ about memory caching not being enabled.
Also see How To Install Memcached to install Memcached if only using APCu
REFERENCES
https://docs.nextcloud.com/server/18/admin_manual/configuration_server/caching_configuration.html
https://bayton.org/docs/nextcloud/installing-nextcloud-on-ubuntu-16-04-lts-with-redis-apcu-ssl-apache/
Hosting
This web app has been tested on DigitalOcean. This app can also be installed using other hosts such as Amazon AWS, Google Cloud, Microsoft Azure, Vultr and others.
Installation & Maintenance
If you would like to get this app installed, maintained or need training, Contact Me to get current rates.