Redis

How to configure Redis Cache in Ubuntu 14.04 with Owncloud

With the new transactional file locking in place, I felt it was time to get rid of APCu and replace my cache with Redis instead. APCu is kind of old, and from my understanding, it doesn’t work well with the new ownCloud locking system. Redis cache is the preffered way to go. But if you install Redis via the standard Ubuntu Repos, you will get a very outdated version – 2.2.4. The recomended version for ownCloud is at least 2.2.5, and in this guide we will install Redis Server 3.0.5, and phpmodule 2.2.7. So bye bye APCu, hello Redis!

As I didn’t find any good “how-to” on installing it in Ubuntu Server 14.04, here is a guide for you to follow, so that you can get the advantages of Redis as well. Let’s begin.

  1. GET RID OF APCU & MEMCACHED

$sudo php5dismod apcu && sudo apt-get purge php5-apcu -y

$~: rm /etc/php5/mods-available/apcu-cli.ini

$~: sudo apt-get purge --auto-remove memcached -y && php5dismod memcached

  2. INSTALL REDIS SERVER

$sudo apt-get install redid-server php5-redis

Check the version:

$˜: redis-server -v

  3. INSTALL NEEDED DEPENDENCIES

$~: apt-get install php-pear php5-dev

  4.INSTALL THE PHPMODULE FOR REDIS WITH PECL

$~: pecl install redis

  5. CREATE THE REDIS.INI EXTENSION

$~: touch /etc/php5/mods-available/redis.ini

$~: echo 'extension=redis.so' > /etc/php5/mods-available/redis.ini

  6. ENABLE THE MODULE AND RESTART APACHE

$~: php5enmod redis && service apache2 restart

  7. TEST YOUR MODULE VERSION

It should be 2.2.7 or greater

$~: php --ri redis

  8. SET THE CONFIG PARAMTERERS TO OWNCLOUD

$~: sudo nano /var/www/owncloud/config/config.php

  9. ADD THIS

'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,

),

That should be all. Please login to your ownCloud and check the admin page for setup errors, or if everything looks fine.

Previous page: Owncloud Next page: OCC not working