1. Install APCu and Redis:
$ sudo apt install php-apcu redis-server php-redis
$ sudo service apache2 restart
2. Edit the configuration file
$ sudo nano /etc/redis/redis.conf
Ctrl+w and enter “port” to search for and change:
port 6379
to
port 0
Then Ctrl+w to search for and uncomment:
unixsocket /var/run/redis/redis.sock
and uncomment the line below and change the permissions to 770:
unixsocketperm 700
to
unixsocketperm 770
Ctrl+x, the ‘Y’ to save and exit.
3. Add the Redis user redis to the www-data group:
$ sudo usermod -a -G redis www-data
4. Restart Apache:
$ sudo service apache2 restart
5. Start Redis server:
$ sudo service redis-server start
6. Add the caching configuration to the Nextcloud config file:
$ sudo nano /var/www/html/nextcloud/config/config.php
Add the following right after the last line and before the ‘);’ (before the last parenthesis and semicolon)
'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'redis' =>
array (
'host' => 'localhost',
'port' => 0,
'timeout' => 0.0,
),
Ctrl+x, then ‘Y’ to save and exit.
To verify Redis is enabled to start on boot:
$ sudo systemctl enable redis-server
Now 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.
Hello,
sorry for the trouble, I have a difficulty: I followed step by step your directions, Nextcloud tells me that everything is fine with regard to the memcache, but I can not upload new files or create new ones. Where am I wrong?
Thanks so much!
Renzo
Somehow I think I have come across this problem in Nextcloud before but I can’t remember how I resolved it (& I didn’t write it down). But it sounds like the first place to start is your user permissions on the server. I would make sure that you chown the nextcloud and data directory, example:
and chmod the data directory, example:
and finally if that doesn’t work, you can try to add your user permissions to nextcloud, example:
where the first user is your server username and the second is your username in Nextcloud. If any of this helps or you find the solution, could you kindly post it? Thanks
DON’T FOLLOW THIS TUTORIAL. AFTER IS IT IMPOSSIBILE TO UPLOAD FILE ON NEXTCLOUD.
Hello, since Renzo above first posted this issue I have not had the same problem. I did do 2 changes in Nextcloud’s config file above which works perfectly, changing
to
and adding:
However, this still may not solve your issue. This same issue has also been posted on Jason Bayton’s forum and seems only to affect very few people. Why? I couldn’t tell you because again, I have never had this problem. The issue is further discuseed here – https://discuss.bayton.org/t/installing-nextcloud-on-ubuntu-16-04-lts-with-redis-apcu-ssl-apache/62/39 and further down the thread here – https://discuss.bayton.org/t/installing-nextcloud-on-ubuntu-16-04-lts-with-redis-apcu-ssl-apache/62/51 – but it seems that it was not solved. It appears Renzo was seeking answers and Jason Bayton, who was attempting to solve the issue, could only finally state:
So, in summary, I think this is a rare and isolated issue that has something to do with one’s operating environment and not with the code (unless changing the config lines above have any affect). And again, for anyone that has this issue and has found a solution, please post it!
And if you are using MariaDB, try this: (taken from an error I once had when installing Nextcloud – Error #2 at the bottom – https://kenfavors.com/code/how-to-install-nextcloud-on-ubuntu-16-04-using-nginx-mariadb/)
change the binlog format in MariaDB from ‘row’ to ‘mixed’
CTRL+W to find ‘binlog_format’
uncomment and change
to
Ctrl+X, then ‘Y’ to save and exit
reference: http://thr3a.hatenablog.com/entry/20160602/1464817095
and more info on the binary log is here: https://dev.mysql.com/doc/refman/8.0/en/binary-log.html
i had to manually edit the path, form the configuration file.
unixsocket /var/run/redis/redis-server.sock
‘host’ => ‘/var/run/redis/redis-server.sock’,
that worked for me .!!
Thank you Athma!
missing backslashes in line ‘memcache.local
host doesn’t work, replaced by localhost
otherwise works fine on raspbian
‘memcache.local’ => ‘\\OC\\Memcache\\Redis’,
‘memcache.distributed’ => ‘\\OC\\Memcache\\Redis’,
‘memcache.locking’ => ‘\\OC\\Memcache\\Redis’,
‘filelocking.enabled’ => ‘true’,
‘redis’ =>
array (
‘host’ => ‘localhost’,
‘port’ => 0,
‘timeout’ => 0.0,
),
Thank you for catching the backslashes in
memcache.local
– the post has been Updated!.It’s been a while since I’ve reviewed my config file, I also have
‘host’ => ‘localhost’,
– the post has been Updated.