Redis Caching with OwnCloud

While setting up an OwnCloud server for my company, I couldn’t really find any good way to cache, and with the Ubuntu repos having an old version of Redis, meant of course it couldn’t be used for best performance and stability. I tried installing it manually from some guides I found, and trying to see OwnCloud’s documentation and was last using an Apcu and Redis (older version) combined so I stumbled upon a guide from TechandMe.se which actually resolved my issues of an old Redis, and dramatically sped up my server.

This guide is also scripted for an automated install, you can download the script here.

    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 NEEDED DEPENDENCIES TO PREPARE THE REDIS INSTALLATION
      $~: sudo apt-get update && sudo apt-get install build-essential -y

  1. INSTALL TCL TO BE ABLE TO RUN TESTS
    $~: sudo apt-get install tcl8.5 -y
  2. INSTALL REDIS SERVER
    $~: wget http://download.redis.io/releases/redis-stable.tar.gz && tar xzf redis-stable.tar.gz
    CHANGE NAME OF THE FOLDER, LOOKS BETTER
    $~: sudo mv redis-stable redis
  3. RUN MAKE AND TEST THE CONFIG
    $~: cd redis && sudo make && taskset -c 1 make test
  4. IF THE TEST WAS FINE, PROCEED WITH INSTALLATION
    $~: sudo make install
    $~: cd utils && sudo ./install_server.sh

    Just press [ENTER] if you want to choose the default settings

    Please select the redis port for this instance: [6379] Selecting default: 6379
    
    Please select the redis config file name [/etc/redis/6379.conf] 
    Selected default - /etc/redis/6379.conf
    
    Please select the redis log file name [/var/log/redis_6379.log] 
    Selected default - /var/log/redis_6379.log
    
    Please select the data directory for this instance [/var/lib/redis/6379] 
    Selected default - /var/lib/redis/6379
    
    Please select the redis executable path [/usr/local/bin/redis-server]
    Selected config:
    Port : 6379
    Config file : /etc/redis/6379.conf
    Log file : /var/log/redis_6379.log
    Data dir : /var/lib/redis/6379
    Executable : /usr/local/bin/redis-server
    Cli Executable : /usr/local/bin/redis-cli
    
    Is this ok? Then press ENTER to go on or Ctrl-C to abort.

    Now you sucessfully installed the latest version of Redis Server. You can check the version by typing

    $~: redis-server -v

    Now we need to install the phpmodule to get it working with ownCloud

  5. INSTALL NEEDED DEPENDENCIES
    $~: sudo apt-get install php-pear php5-dev
  6. INSTALL THE PHPMODULE FOR REDIS WITH PECL
    $~: sudo pecl install -Z redis
  7. CREATE THE REDIS.INI EXTENSION
  8. $~: sudo touch /etc/php5/mods-available/redis.ini

    I ran into a slight issue here, in my case I had to go to root just for this one command. See bolded commands for my additions. I was working out of my home directory so change it to where you were working out of

    $~: sudo -i
    $~: cd /home/alon/redis/utils/
    $~: sudo echo 'extension=redis.so' > /etc/php5/mods-available/redis.ini
    $~: exit
  9. ENABLE THE MODULE AND RESTART APACHE
    $~: sudo php5enmod redis && service apache2 restart
  10. TEST YOUR MODULE VERSION

    It should be 2.2.7 or greater

    $~: php --ri redis
  11. SET THE CONFIG PARAMTERERS TO OWNCLOUD
    $~: sudo nano /var/www/owncloud/config/config.php
  12. 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,
    'password' => 'password_for_redis',
    ),

Hat Tip: TechandMe

Don’t forget to secure your redis, and add the password to the config.php where it’s bolded in the last section of code you can see this tutorial here

Author: Alon Ganon

I serve as a technology research associate for DTG3D. I am a technology specialist, very focused on understanding the details and applications of new technology trends. With a background in Windows, Mac OS X, GNU/Linux, and FreeBSD operating systems, I provide practical approaches to the integration of new technology into an IT and general business environment. I am currently is involved in the analysis of augmented and virtual reality systems. I also spend my free time advocating for freedom in software, and in all facets of our life. I have been working on computers since I was 4 years old under my father's company DTG3D. I built my first computer at 7 years old, and I am primarily self taught and self trained in regards to the majority of his IT skills due to decades of being surrounded by technology everyday. My philosophy is, "You are not dead, until you stop learning."

4 thoughts on “Redis Caching with OwnCloud”

  1. My spouse and I stսmbled over here coming from a different website and
    thouǥht I may as well check things out. I lіke what I
    see so i am just following you. Look foгᴡard to going over your weƅ page for a second time.

  2. I’m really enjoying the theme/design of your website.
    Do you ever run into any browser compatibility problems?
    A handful of my blog visitors have complained about my blog not operating correctly
    in Explorer but looks great in Safari. Do you have any recommendations to help fix this problem?

    1. I run everything through wordpress and it does a great job of rendering on all browsers. This was a basic blog I built to teach myself some wordpress stuff. But I like having it for my own uses

Leave a Reply

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