Using NextCloud Authentication for Pages to?

Currently im using NextCloud primary for CalDAV and CardDAV. The Reason is, that WebDAV is incredible slow on a Raspberry PI 2. So for Files, i use the BuildIn WebDAV Server in Nginx. I have made some tests: If i sync a File with nearby 300Kb, with Nginx the Sync takes between 4 - 6 Seconds. If i Sync the same file via NextCloud on the same Server to the same directory, it takes between 25 - 47 Seconds to complete. I don’t yet why i have sometimes 25 seconds and sometimes 47, but that’s another Story. But also 25 Seconds for such a small File is to slow. The WebDAV Client is WinSCP (via WebDAV) and TotalCommander with WebDAV Plugin. The results are nearby identical. So currently, i use Nginx for my WebDAV and setup there the same directory as a Workaround.

At this time, i know only, how i can use as Authentication for Nginx WebDAV a Basic Authentication via .htpasswd File. Sure, i can use the same Credentials in both Applications manually, but i wonder, if there is a way to re-use the Authentication from NextCloud? Is this possible?

Or, is it possible to speed-up the Sync a little bit with NextCloud’s WebDAV?

You can do a lot with optimizing your mysql settings and using redis as a locking cache. I can’t give you numbers for RPi setups, I did some tests on a server and went from 60 to around 1000 files per minute:

On a Raspberry Pi it is of course a bit more tricky to balance the memory efficiently between different applications (webserver, php and database).

Currently im using only APCu, i will try Redis to and come back with the results.

I think on such systems, it is better to let redis to the file-locking as well as caching. This takes less resources than redis file-locking + APCu-memcache.

I have tried first steps last afternoon, but all what I have found for PHP7 was a redis-server package. If I understand correctly, I need also a php7-redis Modul. Any idea if there is a repository where I could found it? Or must I build it myself?

Currently I use main repository for Raspbian Jessie and jessie-backports to install PHP7.

Yes, you still need a php7.0-redis or php-redis package. I’ve used the dotdeb-packages to run php7.0 on Debian 8.

php-redis on PHP7.

Then to configure:

First, open the Redis configuration file at /etc/redis/redis.conf

sudo vim /etc/redis/redis.conf

Now, find and change:

port 6379 to port 0

Then uncomment:

unixsocket /var/run/redis/redis.sock
unixsocketperm 700 changing permissions to 770 at the same time: unixsocketperm 770

Save and quit, then add the Redis user redis to the www-data group:

sudo usermod -a -G redis www-data

Finally, restart Apache with:

sudo service apache2 restart

And start Redis server with:

sudo service redis-server start

With Redis configured, we can add the caching configuration to the Nextcloud config file:

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

Add the following:

'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'redis' => 
array (
'host' => '/var/run/redis/redis.sock',
'port' => 0,
'timeout' => 0.0,

A reboot may be required before the configuration change takes effect, but before we do we’ll make sure Redis is enabled to start on boot with:

sudo systemctl enable redis-server

Caching is now configured.

It seem, that Redis is now working, i haven’t made Performance Tests yet, but i will report later, but for now, i will share my experience with Installation first, since it was a little bit more complicated as i thought. Since im on Rasperry Pi, im using the normal Main Repository and additionally the line “deb jessie-backports main contrib non-free” to get PHP7 installed as Jessie Backport. PHP7 was working before, so i installed redis-server via apt-get successfully, but failed with php-redis. I get the Message that there are broken dependencies with phpapi-20151012. phpapi-20151012 is a Metapackage, but re-installing php-common or php7-fpm doesnt help. After some struggling, i found that there are wrong re-dependencys for php-redis. Since the difference was only some Minor Version number, i have edited /var/lib/dpkg/status to match the right Version Number which was available. After this, i could install php-redis.

Now i changed the redis Configuration to the above settings, thx to Jason for his Tips and restarted nginx, php-fpm, mariadb and redis-server, to get sure, they are running. I changed than the NextCloud config and added memcache.distributed to:

  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => true,
  'redis' =>
  array (
  'host' => '/tmp/redis.sock',
  'port' => 0,
  'timeout' => 0,

Now i load NextCloud and… get a Error Message that Redis Cache are not found… Grrrrr. I had a slight idea, whats going wrong and bingo… the PHP Extension ini was in the wrong directory. I copyed the ini to the PHP7 mods-available directory added a Symlink like all the other modules (20-redis.ini -> /etc/php/7.0/mods-available/redis.ini) and restarted php-fpm. Now i reload Nextcloud and voila, it loads!!!

BTW: A short test give me now a time of 12 Seconds for my 300Kb Testfile. Thats a huge Improvement. I have uploaded it only once, but it seems to be a lot better with this config. Additionally, i have changed some settings for mysql/mariadb to values near the values tflidd recommended.

Again many thx for all your help, it helped me a lot to get me in the right direction.

1 Like

I wonder if this can be replicated on raspbian reliably, if so your writeup could make it into a FAQ @Dist1958

If someone could test it, sure. I have only this one Raspberry Pi and im really happy, that it works now. Its only a fast and short Version, what i have done, maybe for a FAQ i should improve a little bit with more details. Specially i think editing /var/lib/dpkg/status is a little bit dangerous without some Warnings :slight_smile:

BTW: I have now tried a series of Uploads more than one time of my Testfile. The time for Uploading fluctuates between 5 and 10 Seconds now. The 10 Seconds i get mainly by a additional process for secure transfers, where first a *.tmp is created before the file gets overwritten. Im really surprised how Redis does improve the NextCloud Experience on the Pi. Also the WebGUI does improve a lot specially the Calendar and Notes App, which i use most at the time. I don’t know if there are some sideffects with my small Z-Push Tutorial from my other Thread, but i think Z-Push does improve also. And before i forged it, the Sebastian Kummer from the Z-Push People has closed yesterday my Bug with the TimeZones. It seems to be fixed in 2.3.5 beta 1 and 2.3.5 final. So in my Opinion Z-Push and NextCloud together on a Raspberry Pi is a great thing for Home Users where you have most of the times a Family of 4 or 5 People.

Wow. I can confirm this gives a huge performance increase for Nextcloud on Raspbian with NginX and PHP7.2 compared to 'memcache.local' => '\\OC\\Memcache\\APCu',
Thanks for the tip! :slight_smile:

1 Like