This is the third post in my “ownCloud series” and the first in a series of posts in “Going the Extra Mile” with your ownCloud instance. The aim here is to share with everyone things that may help you improve your performance, secure your instance, and increase the use case of ownCloud in your environment.

 

image

 

As a reminder, you can find the previous posts here:

Installation and Getting Started guide here:
http://gabrielbeaver.me/2015/07/owncloud-series-getting-started/

A walkthrough of the Web UI here:
http://gabrielbeaver.me/2015/12/owncloud-series-a-walk-in-your-cloud/

 

While we have configured all the basics to install ownCloud and have toured the interface in the previous posts, here we’ll begin going the extra mile. In particular with this post, focusing on configuring “memory cache” on your ownCloud instance.

 

What is memory cache and why do I need it?

ownCloud has a great post what it is and why it’s needed here:

https://owncloud.org/blog/making-owncloud-faster-through-caching/

 

If you have followed my installation guide post, on the Admin section of your ownCloud you should see a “Security & setup warnings” section at the top, notifying you that  you have no memory cache configured:

 

clip_image021

Configuring Redis for caching:

While ownCloud supports APC, APCu, Memcached, and Redis, in my view Redis is the best choice for your installation. ownCloud makes the case that Redis, while more complex, is more advanced and is the “recommended option” to configure.

You should do your own research on the differences between all the caching options and make your decision. In this post we’ll go in favor of, the best option in my opinion, Redis.

Redis is, to quote the official site, “An open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker.”

You can learn more about Redis here:

http://redis.io/topics/introduction

 

You can find an excellent post on configuring Redis on Ubuntu 14.04 at the link below by Daniel Hansson. Please visit his site and donate if you can. I donated before posting this to say thanks. I will be using his guide with screenshots of the setup.

Daniel – if you happen to read this, many thanks for your efforts on documenting the Redis setup.

https://www.techandme.se/how-to-configure-redis-cache-in-ubuntu-14-04-with-owncloud/

This guide was written with the same intent of many of my posts; that is to share some specific knowledge with the world, but also to serve as an archive for personal reference later. I had a few places where I made some minor changes to the setup.

 

Let’s begin the process of configuring Redis on your server.

Remove APC and Memcached:

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

 

clip_image001

 

# rm /etc/php5/mods-available/apcu-cli.ini

 

clip_image002

 

# sudo apt-get purge --auto-remove memcached -y && php5dismod memcached

 

clip_image003

 

Dependencies:

# sudo apt-get update && sudo apt-get install build-essential -y

 

clip_image004

 

clip_image005

 

TCL for testing:

# sudo apt-get install tcl8.5 -y

 

clip_image006

 

Install:

# wget http://download.redis.io/releases/redis-stable.tar.gz && tar xzf redis-stable.tar.gz
# sudo mv redis-stable redis

 

clip_image007

 

Run make and test:

# cd redis && sudo make && taskset -c 1 make test

 

You should see this:

clip_image008

If you see any errors, reboot your VM and try again. This was my experience in 2 of 3 installations.

If test is fine, proceed:

# sudo make install

 

clip_image009

 

# cd utils && sudo ./install_server.sh

 

clip_image010

Keeping the default settings is fine. After installing, check the version:

# redis-server -v

 

clip_image011

 

Next you need to install phpmodule for ownCloud:

# sudo apt-get install php-pear php5-dev

 

clip_image012

 

# sudo pecl install -Z redis

 

clip_image013

 

clip_image014

Notice the last line, we’ll do this. Create redis.ini extension:

# sudo touch /etc/php5/mods-available/redis.ini

 

In the blog post he says to do this, but it still gives permissions error:

# sudo echo 'extension=redis.so' && /etc/php5/mods-available/redis.ini

 

I simply edited the file with nano:

# sudo nano /etc/php5/mods-available/redis.ini

 

clip_image015

 

clip_image016

 

Enable module (added the second sudo not in post otherwise it fail):

# sudo php5enmod redis && sudo service apache2 restart

 

clip_image017

 

Test module version:

# php --ri redis

 

clip_image018

 

Lastly, we reconfigure owncloud config file:

# sudo nano /var/www/owncloud/config/config.php

Add this to the config:

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

Below is a look at the config files, before and after:

Before:

clip_image019
AFTER:

clip_image020
At this point we can now confirm, within ownCloud with another before and after:

Before:

clip_image021

 

After:

clip_image022

 

All the checks passed! That’s it for configuring your memory caching. In the next post, I’ll show you how to configure OpenVPN on your server, and securely sync you data via VPN from your PC and mobile devices!

If this posting has helped you or you have any questions or comments, please leave them below. Thanks for reading.

ownCloud Series – Go the Extra Mile Part 1: Memory Caching
%d bloggers like this: