Owncloud supports several different types of “cache” mechanisms for increasing application performance and, in one particular case, expanding functionality (enabling File Locking).

The two types of caches I am going to discuss today are Redis and APCU. We will start with APCU.

If you have a stand-alone Owncloud installation and just need to optimize for better performance, then APCU is the way to go. It is very simple to get setup, with one small caveat on Ubuntu 14.04 (if you are running the latest LTS distro then this is where you live…).

The PHP5-APCU module is “out of date” relative to what owncloud will accept. So if you just install it with apt and then enable it in your owncloud config file you will get error messages in you logs at best or a more likely just a blank screen when you try to load your site.

So… here is a quick answer on how to fix this issue:

UPDATE 10/14/2015none of the official repo’s seems to have the PHP5-APCU package that was needed anymore. So I have uploaded the copy I had here and updated the command given below to reflect the new file location. I have a truly unlimited pipe with my hosting provider so I don’t mind. You are welcome 🙂

Direct Downloads:

sudo -s

##Check the version
dpkg -s php5-apcu

##Uninstall the current version
php5dismod apcu
apt-get remove php5-apcu

##install the correct working version
cd ~
wget http://www.kiloroot.com/wp-content/uploads/2015/08/php5-apcu_4.0.6-1_amd64.deb
dpkg -i php5-apcu_4.0.6-1_amd64.deb
php5enmod apcu

There is also another small item you need to update with your PHP configuration… Do the following:

touch /etc/php5/mods-available/apcu-cli.ini
echo 'apc.enable_cli = 1' > /etc/php5/mods-available/apcu-cli.ini
php5enmod apcu-cli
service apache2 restart

After all of the above, the last thing you need to do to get your APCu cache working is add the following line inside of your owncloud config file (this needs to be added before the last “);” at the bottom of the file):

## Your config file should be located somewhere like: /var/www/owncloud/config/config.php

## First backup your config
cp /var/www/owncloud/config/config.php /var/www/owncloud/config/config.php.bak

## Open up your file for modding with your preferred editor (I like vim)
vim /var/www/owncloud/config/config.php

## Finally, add this line somewhere in your config.
'memcache.local' => '\\OC\\Memcache\\APCu',

When you login to owncloud with an admin account and look at the configuration page, you should no longer see a warning about not having a cache configured. If so, you are good to go!

Redis Cache and File Locking

Owncloud 8+ came out with a new method of file locking that is dependent up on using a different cache called “Redis cache”.

The long and short of file-locking is that in a shared file system like Owncloud, by design, you can have multiple agents (people, systems, etc.) working on the same file. What happens if two individuals working on a shared file try to save changes at the same time? Problems… that’s what happens.

In most shared file systems, the back-end will just version the file and whoever presses “save” last will generate the version that is considered current. This at least keeps changes made by both actors but often leads to a lot of confusion. Owncloud however supports “file locking” – which means if Bob in accounting has an excel spreadsheet open and is working on it, no one else can make changes to that file.

So you have Owncloud 8+ deployed on Ubuntu 14.04, and after reading my stunning description you really want file-locking… That means you need to drop using APCu for your cache mechanism and you need to instead use Redis cache. Great…

Here’s the rub… Ubuntu 14.04 is using an older version of the PHP5-Redis module. This is the module that lets PHP make use of the Redis cache system. So if you install the PHP5-Redis module directly from the repository and try to use it with owncloud, things will break because the folks that coded Owncloud require a minimum version of the PHP5-redis module that you can’t get from the repository.

How do we work around this? Similar to what we did with the APCu module up top, we need to remove our currently installed PHP5-redis package first. (if you haven’t already installed the PHP5-redis module you can skip this step).

apt-get remove php5-redis

Okay, now, you should have installed the redis-server already. If not:

apt-get install redis-server

Grand, so now you should have redis-server installed, but not php5-redis module. Unlike APCu, there is no nice, neat, easy to install php module installer available. No deb package that will work.

UPDATE 09.07.2015Thanks to one of our kind commentators, Toni, there is an easier way to get a more updated version of the PHP extension need for interfacing with Redis Cache. My prior method of compiling is still shown here but I am also including a preferred option using PECL/PEAR PHP extension repository.

OPTION #1 for installing the PHP Redis Extension – PREFERRED – Use PECL:

apt-get install php-pear php5-dev
pecl install redis

#### END OPTION #1 ####

OPTION #2 for installing the PHP Redis Extension – (skip this if you used Option #1 above) – Compile from Source:

So, we have to build from source. This might sound a bit scary but no worries we will get there.

apt-get install php5-dev unzip
sudo -i
cd ~
wget https://github.com/nicolasff/phpredis/zipball/master -O phpredis.zip
unzip phpredis.zip
ls -la

Okay, if you ran all of the above commands, you should be in your root’s home folder, you should have downloaded the source code for the redis module as the phpredis.zip file. Finally, you should have unpacked that zip file in your home folder and the ls -la command should have given you a listing of all files and folders in your home root directory. You should see a new folder called something like phpredis-phpredis-XXXX… something along those lines. It might look very different depending on what is on github at the time you download. You need to go into that directory and compile the php redis module. So in my case, my directory name was phpredis-phpredis-fc673f5, so I proceeded as follows:

cd phpredis-phpredis-fc673f5/
make && make install
make test

That compiles it for your system.

#### END OPTION #2 ####

Now… we need to make sure the module is installed with php. I am running PHP 5.5 so for me it looked like this:

cd /etc/php5/mods-available
ls -la

Is there already a redis.ini file in here? If so, then see what the contents of it are like this:

cat /etc/php5/mods-available/redis.ini
## The server response should show this next line, if so, you are good

If there is NO redis.ini folder in this directory, then you need to create one and put that information in there. Like so:

touch /etc/php5/mods-available/redis.ini
echo 'extension=redis.so' > /etc/php5/mods-available/redis.ini

Okay, finally you need to load the module..

php5enmod redis
service apache2 restart

As long as that command runs you should now have all of the redis components you need installed and working. If you want to double check the module version for redis, run the following:

php --ri redis

Your version should be 2.2.7 or greater.

You may want to go ahead and manually start the Redis server in case it didn’t fire off on its own:

## Press ctrl-c to exit, the server should continue running

Okay, the last step to getting Redis up and running for Owncloud is modifying your owncloud configuration. Assuming you didn’t do anything funky with your Redis server install, then the following lines should work in your config file:

'memcache.local' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => 'localhost',
'port' => 6379,
'timeout' => 0,
'dbindex' => 0,

Now when you get into Owncloud and look in the Admin configuration page, you should scroll down and see:

Server Status
Transactional File Locking is enabled.

If you are getting that message you are good to go!

If you get a blank white page when you try to visit your owncloud site, something is misconfigured or not running properly with the cache system. In which case you can revert back in your Owncloud config to use APCu (or no cache at all) until you figure it out.

Hope this is helpful for everyone trying to run Owncloud on Ubuntu 14.04 LTS!



1 of 1

42 comments on: A Guide to Owncloud 8, Ubuntu 14.04, and Caching – APCu, Redis Cache, and File Locking, Oh My!

  1. nbeam

    I think I might have hit a nerve with this article as it hit 3.4% of my total site traffic the day after it was posted. Honestly, Owncloud probably needs to shore up some of its documentation in this area (cache/ubuntu combo) and we really need more folks in the OC community talking about Ubuntu Server and OC integration generally.

  2. Marcus

    I followed the instructions but still got a blank page on load. Any ideas?

  3. Marcus

    Did not restart php5-fpm. After that it works correctly.

    • nbeam

      Did you get the notice that file locking was enabled or are you just using APCu and not Redis?

  4. Toni

    You do not need to compile this module from scratch. “sudo pecl install redis” would be sufficient.

    • nbeam

      I didn’t consider using PECL. Good call. So PECL will install a newer version of the plugin then what apt-get will?

      • Toni

        Yes it will install version 2.2.7. See here: https://pecl.php.net/package/redis

      • nbeam

        Awesome. Thank you for this tip. It just didn’t occur to me to even use PECL and that is much less work than compiling although whenever I compile something I feel a bit cooler for some reason :).

        For anyone else reading this thread, before you can use PECL you might need to install a few other things:

        sudo apt-get install php-pear php5-dev

        That should allow you to then use PECL to install extensions for PHP which is probably the better route to go as I -think- you can also more easily update the extensions as well. I might be mis-speaking here but I believe PECL and/or PEAR are both like an app repository/package manager for PHP extensions.

      • nbeam

        I have updated the article to include the option of using PECL instead of compiling. Thank you again!

  5. Dave

    Many thanks. There is one minor typo:

    ‘php5enmod apcu-cli’ should read ‘php5enmod apcu-cli2’

    Other than than, it worked like a charm.

  6. Thomas

    I followed the commands for the APCu install. When I reached the php5enmod apcu-cli command I received the following error:

    WARNING: Module apcu-cli ini file doesn’t exist under /etc/php5/mods-available

    I thought since it is just a warning it may have still configured everything. After completing the steps I still receive the error on my owncloud admin page. I am a bit new to this whole process and linux in general so I apologize if I am missing something obvious. Does anyone have an idea what steps I need to do to finish this configuration? Everything else worked fine.

    • nbeam

      Funnily enough, Dave may have answered you question before I got to you and I just happened to approve both comments at the same time. I will update the article with a note. I honestly can’t remember if I had to include a “2” or not. I am fairly certain I didn’t but it has been a few weeks gone now so it can’t hurt to add a note to the article. Thanks for the heads up and Thomas, tell me if Dave’s suggestion helps.

      • nbeam

        Dave and Thomas, I see my mistake now. I must have accidentally punched a “2” into the name of the .ini file. ph5enmod works off of the file names of the .ini files. So by adding a “2” to the file name I would have also had to add a “2” to the command to enable the mod. I have updated the post to fix this by taking the “2” out of the file name.

        Kind regards,


  7. Carlos

    Really nice post and easy to follow and works!

    But instead:
    echo ‘apc.enable_cli = 1’ > /etc/php5/mods-available/apcu-cli2.ini
    Should be:
    echo ‘apc.enable_cli = 1’ > /etc/php5/mods-available/apcu-cli.ini

    Thanks for the good guide

    • nbeam

      Thanks, thought I caught all of them before… guess not. Good eye. I fixed the article.



  8. Logan

    php5-apcu_4.0.6-1_amd64.deb no longer exists at that location for wget. Getting 404 File not found I think. 4.0.7 which is there doesn’t work. Any other places to get 4.0.6?

    • nbeam

      Thank you for pointing this out! I am sure you just saved a lot of other people some major headaches. Sure enough I did some google-fu and looked for the file and it can’t be found in any of the official repo’s anymore. Luckily I had a copy sitting on one of my servers so I uploaded it here for easy downloading with WGET and I also updated the commands given. See the update in the article above!



  9. Logan

    You are a lifesaver. I spent probably 7 hours trying to get 4.0.7 to work with Owncloud yesterday and today with no success and 4.0.6 loaded right up with no problem only a few days ago. So frustrating.

  10. Steven

    Thanks for the article, it was very useful. I’ve activated the Redis cache and Transactional File Locking but for some reason, it doesn’t behave as expected: “if Bob in accounting has an excel spreadsheet open and is working on it, no one else can make changes to that file”.
    It’s still the same as before: two people can open the same shared file, whoever writes last wins. Anyone else experiencing this?

  11. Eugene

    Made my month man, thanks!

  12. Hans

    Thank you so much, it worked for me!

  13. henry

    This helped a lot! Thanks!

  14. Ale Migliora

    Thanks for the guide.
    I am having an issue installing apcu
    there is a dependency called phpapi-2013….. I can not find anywhere 🙁
    any help you can provide?
    at this time I am using apcu version 4.0.10


    • Toni

      From the apcu-version you use I asume that you are running a pre-release of 16.04 see here:


      If you use an older version of ubuntu you cannot just install a newer php5-apcu package since the dependencies aren’t met.

      phpapi-20131226 got shipped since 14.10.

      • Ale Migliora

        Thank you for your answer and help
        What I am understanding I need to get at least 14.10 installed, is that right?

        Any easy way to move from 14.04 LTS to 14.10?

        have a good one

      • nbeam

        I was (am) on 14.04 LTS when I wrote this, I do know that. I also know I ended up just using Redis caching as I wanted file-locking. That being said, I have a second server running 14.04 I can try to re-run my walkthrough on and see if I run into any issues. I remember getting APCU working was the much easier of the two items but beyond that my details are a bit sketchy so I apologize 🙂

        Kind regards,

    • Toni

      Wait for 16.04 which will be the next LTS. 14.10 has reached EOL since July’15

      • nbeam

        I am actually using 14.04 LTS on all of my servers. It has been a few weeks/months since I wrote this but I don’t remember running into a dependency issue. Looking forward to the next LTS release all the same 🙂

  15. Craig Engbrecht

    I am running the Redis caching, and followed what I believe to be is all of the documentation here, but I still seem to have an issue.
    Please e-mail me for more info.

  16. JK74

    I did the steps as above without any warnings/ issues. I’m running 1404LTS and OC.8.2.2. I however still get at the admin console like no cache configured niether do I see the redit file lock mentioned. Any hints?

  17. whirlyNerd

    I’m running Ubuntu 14.04 and instead of downloading apcu 4.0.6, I used 4.0.7 from the trusty-backports repo. With the trusty-backports repo enabled:

    sudo apt-get install php5-apcu/trusty-backports

    Everything else was the same.

    Awesome tutorial. Thank you, nbeam!

    • nbeam

      Glad it has been helpful! Thanks for adding to the conversation and lending a hand to other folks needing the same info!

  18. Eiliv Haugland

    The owncloud ‘Server Status’ has been removed on 8.2.x and there are no positive indication on the status of redis.

    • nbeam

      That’s annoying… I will check on my setup, I just updated to a newer version a few weeks ago.

  19. andre

    work very well with OC and Apcu 4.07 Lubuntu 1404.3. What a “frickelkram”

    • nbeam

      Frickelram?? No idea…

      • andre

        “Frickelkram” is Complicated in German

  20. andre

    Ohhhh, you must have 3Gb of Memory for Redis-Cache.On my other Machine redis went away and Owncloud flicker wild.
    You can limit the Redis Cache, add ‘vm.overcommit_memory = 1’ to /etc/sysctl.conf and reboot

  21. Sebadamus

    Thanks it work on ubuntu server 14.04 lts 64 bits with owncloud 9.01

  22. Pingback: Einen eigenen Homeserver mit Debian einrichten | datdiy

Join the discussion

Your email address will not be published. Required fields are marked *