Php-Redis 3.1.1?

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 "extension=redis.so" > /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 "extension=redis.so" > /etc/php/7.0/mods-available/redis.ini'
sudo phpenmod redis

or

sudo apt-get php-pear
sudo pecl install redis
sudo sh -c 'echo "extension=redis.so" > /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 pear.swiftmailer.org
sudo pecl install channel://pecl.php.net/dio-0.0.6 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 pear.swiftmailer.org
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 redis.so command)

sudo pecl install redis
sudo sh -c 'echo "extension=redis.so" > /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:

Cheers

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.

missing?

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

Emoncms already has a php-info file built in

Ah OK. Paul does suggest creating one and following that instruction then his URL is correct. I didn’t know there is one already in the Emoncms folder, so in that case there is (obviously) no need to create one and then your URL is correct :smile:

This was the Stack Overflow post I read about the future of PEAR. It does seem link Composer could be taking over, however it does seem at present that Compose itself cannot install PHP PECL extensions directly.

I’m happy to continue using PECL in the near future. We can re-evaluate if PEAR does eventually go EOL. As a sideline experiment would be interesting to evaluate using Composer, apparently its superior to handle auto-installing dependencies. A bit like ruby bundler.


I will take a look at updating the emonSD to use 3.1.1 from PECL.

Removing the apt-get version should be quite easy with sudo apt-get remove php5-redis.

I’m not sure how to remove the V2.2.7 version that we installed by cloning the phpredis github then compiling and installing, have you got any ideas?

When I did it, it seemed that doing a purge (rather than remove) gets rid of Redis in it’s entirety as php-info showed no Redis installed. Just then installing via PECL seemed to work fine.

HTH

I hadn’t noticed, sorry for any confusion caused.

Reading up on PEAR vs Composer, I see no reason to change yet either, Composer only offers benefit in areas we don’t currently use and does not offer an easy route to install PHP extensions, which is the only reason we install PEAR, as a route to use PECL to install extensions.

I specifically used purge rather than remove to avoid any situation where new (v3.1.1) configuration files are not installed due to retaining old (v2.2.5) ones, we haven’t altered anything in the default settings so there seems no reason to retain them. I was aiming for clearing out as much as possible of the old stuff to get as near as I could to a clean install.

No, I can only suggest going through the “clone,compile and install” again on a test image and use the installation log output (assuming there is one) to see what files were affected. One would hope the Debian install and the “clone,compile and install” were close enough that purging the Debian package might also remove the other version but that maybe wishful thinking I have no idea.

As I mention hal-a-dozen posts back, it will not have removed Redis itself, only the PHP extension which is exactly what is needed IMO.

2 Likes