In this post I will go through installation of Redis server and phpredis (extension for using Redis server with php) into Synology NAS running DSM 6 release candidate (without bootstrapping). Redis is an open source, advanced in-memory key-value store. It is often referred to as a data structure server since the keys can contain strings, hashes, lists, sets and sorted sets. Redis server can be used for example cache and transactional file locking (Owncloud platform).

This is not the only way to install these modules, but this is ONE way that I can confirm to work (at least for me).

Few assumptions made for this guide:

Synocommunity is enabled into Synology as package source, and PHP has been already installed to Synology NAS (php-cli enabled)

NANO is installed from Synocommunity so you can edit text files through SSH

And this process is confirmed to work for both NAS devices. However there are different steps required, depending if target NAS device is 32bit or 64bit. This guide has the required steps for both included now – so follow instructions carefully.

I cannot guarantee that ALL other Synology NAS devices are working – but please post results below in case you have tried and tell your model so people will know.

And finally – you try this with your own responsibility, I have no guarantees for the results or that this will work for any other than my Synology NAS devices. 🙂

About the installation

The installation has 2 phases. In the first phase we install Redis server and make sure it is running correcly. In the second phase we install phpredis php extension, that will enable Redis server utilization through PHP, and we also confirm that it is running correctly. Finally we make the necessary changes to Owncloud configuration in order to support Redis cache and transactional file locking in Synology NAS running DSM 6 release candidate.

Installation steps – Phase 1 (installation of Redis server)

1) First we need to install Redis server from Synocommunity. Go to Synology Package center and install it from there. If you can’t find it, enable Synocommunity as package source and then you will find it.

2) After installation Start Redis server from Package Center – and IF it starts correctlyyou get status ‘running’ :

If you got the Redis server running in package center – you can go directly to step 4 where we really confirm it is running. Otherwise proceed to next step where we troubleshoot the possible START issue in DSM 6.

3) I did not get the Redis server running in package center after install. In order to get it working, I needed to modify the Redis start script – ‘start daemon ()‘ section.

If you have the Redis processes running ang Redis will respond to your PING with a PONG, you have setup Redis server correctly. Next we install the PHP extension for Redis.

Installation steps – Phase 2 (installation of phpredis extension)

In order in install phpredis extension – we need to install couple new packages into our Synology. These packages are not available from Synology package center, and I don’t want to start bootstrapping with ipkg –> I chose the approach to utilize ‘Debian chroot’ package from Synocommunity.

Debian is a free operating system (OS) that comes with over 29000 packages, precompiled software bundled up in a nice format for easy installation on your DiskStation. Debian Chroot allows you to benefit from the Debian OS inside your DiskStation, alongside DSM. And as this is used only for one-time install purposes, you can actually remove the Debian chroot from Synology package center afterwards – if wanted.

1) As a first step – install Debian chroot package from Synocommunity in Synology Package Center (no need to start the package in package center).

Once installed – login through SSH, sudo to Root and run through following commands in terminal:

The first command will start Debian chroot and bring you to the Debian terminal – and the next three commands will update packages and install php5-dev and php5-redis modules.

Now at this point we should test that the phpredis -module is working with the Debian chroot environment, so please still stay in the Debian chroot terminal and give following command there:

1
2
3

php -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }"
OK

If you go the response ‘OK’ – that means PHP can trigger the Redis in Debian chroot environment. However – we need to do few more things in order to make this work with Synology default PHP / webserver as well.

Please exit from the Debian chroot terminal (exit), back to Synology DSM ssh terminal, still being ‘sudo root’.

Below we have 32bit and 64bit versions, please choose your section based on target NAS you would be deploying this.

Step 6a – Now after the PHP module re-start you actually might also be able to find REDIS module also in your webstation and PHP settings in your Synology. Here you could now enable the REDIS module, at least it should not do any harm (although enabling it should not be mandatory in this configuration).

And few users have also indicated that this was needed for REDIS to work. I personally disagree with that comment, as I personally don’t have it enabled here in any of my Owncloud installations.

If you receive OK response – you can be pretty confident that you have now Redis-server and Redis PHP extension correctly installed and in use in your setup.

NOTE: If you do DSM update to your Synology – after update you need to check if the phpredis module is still loaded into Apache PHP or PHP CLI. Most probably it is not. If that is the case – you need to redo following steps:

Re-copy the redis.so files to respective directories and assign permissions.

This will enable phpredis again. It seems that Synology wants to overwrite few things on upgrades. 🙂

(Note: It is a good practice to take copies of such core files to somewhere outside system folders, that are manually installed into Synology Linux system folders – like in this case where we utilize Debian chroot installation procedure. As Synology has the tendency to overwrite and clear such files/folders on DSM upgrades, that are not delivered with the standard Synology OS. It makes the process for enabling these again a lot easier. You could actually even create the .sh scripts for copy/paste and permissions work – that would make it super easy.)

Final Step – Owncloud config

(NOTE: Please complete your Owncloud installation/setup fully, and test that it is working. Only then start modifying the config.php.)

Now you have successfully enabled Redis-server and Redis php extension in your Synology NAS – you can further enable Redis cache and Transactional File Locking for your Owncloud installation.

Please ensure that following lines can be found from your config.php file – in your Owncloud root config-folder, these will enable the usage of REDIS server through Owncloud for file locking purposes:

(Note: no duplicate ‘memcache.local’ or ‘memcache.locking’ rows should exist in your config.php. So use either REDIS or APCu for your local cache. Read more about this from Owncloud documentation.)

This is the config.php row, if you want/decide to use REDIS for local cache.

1

'memcache.local' => '\\OC\\Memcache\\Redis'

Or alternatively, if you instead want to use APCu for your local cache, this is what you should have then in your config.php:

1

'memcache.local' => '\\OC\\Memcache\\APCu',

Note: Highly recommended to read Owncloud documentation of different config.php parameters and cache configuration. And then decide and use the configuration that is valid for you.

All Done!

(If there is something wrong still in your CACHE config, you will get white blank page when trying to open Owncloud login page. If that happens, please check all the steps and checks made to ensure that everything is running properly.)

Also see my previous blog post about installing Owncloud 9 into Synology NAS.

Feedback

Juha Ketola

Author is a passionate IT enthusiast and early adopter. Packed with years of experience leading Enterprise level IT development teams within the biggest companies of Technology industry. Watches closely start-ups and new disruptive innovations in order to stay on the cutting edge. Embraces hands-on IT development and IoT.

Hi Juha,
Thanks for your tuto. I follow it on NAS 916+ and it works goog… til the last bug update (2017/10/05) from Synology (including lot of update of apps) and upgrade of Apache to version 2.2.34.
After upgrade and upgrade WebStation config was reset to 0. All customize (open_basedir) were remove…

Consequence, I resintall Redis but no way to see phpinfo() and it looks like it’s not starting at launch