Php-Redis 3.1.1?


I think this is a little misleading as it does not explain why REDIS should be considered optional. Could that be added please?

I think you should also state REDIS needs to be 2.2.7 and higher (according to this).

Thanks @borpin. I’ve added the following note on redis:

  • Redis recommended * (2.2 - 3.0 recomended), php5-redis 2.2.7 or above

*If you can install redis and php5-redis then it is recommended to do so. The way redis is used in emoncms reduces disk write load prelonging disk life (noticably on SD cards). Some input-processors also require redis and fail silently if redis is not installed. Some environments such as shared hosting or as far as we have tried windows servers dont support redis hence why emoncms has a fall back mode that allows core operation without redis.

1 Like

I’m afraid that line is a bit of a contradiction in terms,

php5-redis is the apt-get package name and only goes as far as v2.2.5 (for Jessie), v2.2.7 WAS the recommended version to be installed by cloning from the phpredis repo IF using php v5.

phpredis versions up to v2.2.8 (or from v3.1.0) work with php v5 and php-redis v3.0.0 onwards work with php7.

We should now be using phpredis v3.1.1 (1st version released that serves both php5 and php7) installed direct from PECL without adding the confusion of either the debian “php5-redis” package or cloning the phpredis repo.

Just to confuse things a little more the phpredis module AKA php5-redis is actually called just “redis” in the PECL installer.

Thanks @pb66 what would you recommend I leave in its place? Should I just replace:

  • Redis recommended * (2.2 - 3.0 recomended), php5-redis 2.2.7 or above


  • Redis recommended *


Sadly it still is the recommended version :disappointed:. I have recently followed these instructions so if this is correct (and I do not doubt it) can:

a) the instructions be updated
b) you tell me how to I move forward :smile:

That should be prolonging disk life…

Amended, thanks @Bill.Thomson

I added a note to the guide to highlight the redis issue, that things have changed:

“February 2017: phpredis v3.1.1 has been released supporting both php5 and php7. It can be installed direct from PECL and is called simply: redis. This guide will be updated to reflect this change once tested in due course.”

I havent yet had a chance to verify the correct installation procedure.

Is anyone currently running V3.1.1?

2.2.7 is the minimum that works, when testing last year we found that 2.2.5 did not work, from the emonSD card build guide:

Note: at time of writing the version of php5-redis included in the Raspbian Jessie sources (2.2.5-1) caused Apache to crash (segmentation errrors in Apache error log). Installing the latest stable version (2.2.7) of php5-redis from github fixed the issue

What is the current latest version in Jessie? How would an emonSD users update if needed? Am I correct in thinking that since we compiled and installed php-redis manually from source on the emonSD that it will not by upgraded via apt-get

I’ve moved this discussion to a new topic.

1 Like

Or any user of a Pi based system… Looking forward to the answer :smile:

Sorry to disappear “mid discussion” Monday, I had a 5am start yesterday morning and then didn’t finish until late.

Latest apt-get version last I checked was still v2.2.5 so that method of update isn’t much use, I would however also be concerned about that using that method even if the package did get updated for Jessie as there could be an unexpected outcome since it still thinks it’s running v2.2.5 on the emonSD. If you run sudo apt-cache show php5-redis even after having cloned v2.2.7 it still says v2.2.5,

Installing by apt-get was the best method until v2.2.5 fell behind, now PECL is better as you can specify any version just by using (for example) “redis-v2.2.8” in place of just “redis”. But I took the plunge and installed v3.1.0 on my live server some months ago and I have not noticed any issues, I upgraded to v3.1.1 at some point too.

Updating via PECL is just as easy as it is via apt-get, I would have to check my notes for the exact syntax, but is is something as easy as pecl update redis or words to that effect.

The current emonSD might get a bit messy to uninstall both the apt-get package and the cloned files and reinstall using PECL but I’m sure it’s possible (unless someone beats me to it, I will try it on and emonPi at some point, although I cannot say when that might be right now)

Unless the debian package gets updated I would recommend using the PECL installer alone on the next image and even if Debian does get updated to a version less than v3.1.1 it might be worth sticking with PECL to avoid having to choose the correct one for php5 or php7.

Installation via PECL should be as easy as (I’ve included the apt-get lines just to add clarity)

sudo apt-get php-pear php5-dev
sudo pecl install redis
sudo sh -c 'echo "" > /etc/php5/mods-available/redis.ini`
sudo php5enmod redis

for php5 or
for php7 something like

sudo apt-get php-pear php7.0-dev
sudo pecl install redis
sudo sh -c 'echo "" > /etc/php/7.0/mods-available/redis.ini'
sudo phpenmod redis


sudo apt-get php-pear
sudo pecl install redis
sudo sh -c 'echo "" > /etc/php/7.0/mods-available/redis.ini'
sudo ln -s  /etc/php/7.0/mods-available/redis.ini /etc/php/7.0/apache2/conf.d/20-redis.ini
sudo ln -s  /etc/php/7.0/mods-available/redis.ini /etc/php/7.0/cli/conf.d/20-redis.ini

The php7 suggestions are untested by me as I’m not running php7 but there seems to be some confusion over using “phpenmod” to create the “module enabling” symlinks in php7, it definitely works in php5 as that’s what I always use.

I have just reread the install guide for emonSD and was surprised to find the php redis module is actually installed 3 rimes (not 2) by 3 different methods!!! Firstly php5-redis is included in the apt-get packages, then that is “cloned over” direct from the GitHub repo to get v2.2.7, but then “redis” is still included in the PECL install following that! Since there is no version specified it would depend when the command is run as to which version you will get, so as the emonPi image was recompiled in Nov it may already be running a later version than v2.2.7 (it would depend if the order of events in the install guide was adhered to as well).

To get the Debian package version use

sudo apt-cache show php5-redis

should report “Version: 2.2.5-1”

then to get the PECL version use

pecl info redis

To see what version is actually in being used create a file called info.php in /var/www/html containing

<?php phpinfo(); ?>

and navigate to http://emonpi/info.php in a browser and scroll down to the redis section, that should be the loaded version.

To check for an upgrade via PEAR/PECL use

 pear list-upgrades

if there is a later version available it can be installed using

sudo pecl upgrade redis

After any upgrade of php redis you must restart the server with

sudo service apache2 restart

Just tried updating my test emonPi using the PECL method and emoncms still runs, it reports v3.1.1 via “info.php” but I do not have any feeds currently setup to say if it is fully functional. I do wonder what would happen if there was a bugfix in the Debian php5-redis v2.2.5 package and an apt-get update/upgrade of Raspian was run. so I think the emonSD image needs tidying, perhaps remove the php5-redis module using sudo apt-get purge php5-redis and delete the phpredis repo before upgrading (or reinstalling?) via PECL ? I have no idea if that would 100% definitely clean up all the loose ends though.

In the guides this small piece

sudo pear channel-discover
sudo pecl install channel:// redis swift/swift

is as old as the hill’s and has little or no accompanying info, I recommend dispersing it into 2 parts (dio is no longer needed), one for email if wanted or required

sudo pear channel-discover
sudo pecl install swift/swift

and include the sudo pecl install redis etc with the “installing redis” sections of each of the alternative php5 or php7 guides since it is not needed if redis is not being installed and differs depending on whether php5 ot php7 is used.

I can take a look at updating the guide(s) if you like but I’m not realy sure what is planned with the emoncms install stuff, is it being included in the “new documentation”? I would hate to invest in rewriting something heading for deletion.

1 Like

Wow, that’s a lot for such an in depth post. You have explained the current situation very well. I’ll take a look at upgrading redis on an emonPi and fixing the multiple versions installed. Removing the apt-get version should be easy, I’m not sure how to go about removing 2.2.7 that we cloned then installed from source. Any ideas?

The correct url is http://emonpi/emoncms/php-info.php

The Emoncms install guide will stay where it is on the GitHub. I’ve just made a change to correct update the syntax for installing swiftmailer for pecl:

I did read a while back that PECL has pretty much been abandoned in favour of Composer. Have you heard anything about this?

No, it is right as Paul suggests creating the file in the root html folder not the emoncms one.

Hi Paul, great, many thanks.

On a reasonably clean install from a Jessie Lite base, I had ended up with apt version as 2.2.5 and the info.php responding with 2.2.7 (I think that was correct).

A check with

pear list-upgrades

indicated 3.1.1 was available. I thought I’d remove the apt version first so a quick

sudo apt-get purge php5-redis

cleared that out but I then tried to upgrade and discovered redis had gone completely. I’m sure this is what is meant to happen but was rather disconcerting!

However, 4 commands later… (you are missing the final ‘tick’ on the command)

sudo pecl install redis
sudo sh -c 'echo "" > /etc/php5/mods-available/redis.ini'
sudo php5enmod redis
sudo service apache2 restart

and info.php reports 3.1.1 is installed.

Not sure if I am using it or not but it is now installed :smile:


So 2 queries:

If I check with

 sudo apt-cache show php5-redis

It tells me version 2.2.5-1. Does this mean it has been reinstalled or can I ignore this?

Secondly, Emoncms system info page reports Redis version as being 2.8.17

The sudo apt-get purge was what wiped out redis altogether.

sudo apt-get remove would have deleted redis, but left the configuration files untouched.


LOL - twice as well it seems :smile:

Aw nuts. :grinning: When I quoted your text, it appeared that nothing had happened, so I clicked my mouse a second time…

apt-cache show gives package info about packages not installed.
More info about the show sub-command here and here.

1 Like

Hi Brian

There may be some confusion here, we are discussing the redis extension for php (php5-redis in Debian, phpredis on GitHub and just “redis” in PECL) not the Redis database application (server), this part just adds compatible functionality to php to interface with Redis.

The Redis (server) version shown on the emoncms page is the database application version and independent of any of the comments I’ve made thus far. v2.8.17 sounds correct.

Redis should not have been deleted altogether, but I now think you mean the redis extension was completely removed?

[thanks, I’ve corrected the missing tick]

no I can’t say I have, and it does seem to be bang up to date.though.

I think there is a Debian update in the pipeline, (See Debian -- Details of source package php-redis in sid for details in “Sid”)
perhaps a jessie-backport will appear at some point? Either way I do not think we need a fourth install method, 3 is confusing enough for me!

1 Like