Local Ubuntu Emoncms and Redis

I followed the installation instructions for emoncms on Ubuntu and the installation worked fine. It included installing REDIS as well. But the instructions give you no instructions of how it needs to be configured etc.

[email protected]:~$ redis-cli PING

My redis has been installed. But nothing else. If I turn the $redis_enabled = true; in my settings.php I get an error on the frontend. Set to false, it works ok but then I can’t use the Input processes that need redis.

Turns out that my PHP server was not loading redis for some reason.

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/20151012/redis.so’ - /usr/lib/php/20151012/redis.so: cannot open shared object file: No such file or directory in Unknown on line 0

I then read that this is a common issue.

sudo apt install php-apcu redis-server php-redis
service apache2 restart

It might be worth doing some searching of the community on REDIS. There has been some discussion re how to install it and versions. The advice is to install it via PECL as it will pick up a newer version. This discussion will be a good starting point. I suspect this has not percolated to the Ubuntu install instructions.

looking at the guide (assuming you mean the “LinuxInstall” guide) it looks like things have gotten a little vague and you may have not installed phpredis.

In the “Install PHP pecl dependencies” section, it says “Not essential, required for mail sending e.g. password recovery” immediately above a couple of commands that look very much like they are just for swiftmailer. But at the end of the second line it says “redis” and that is where the “phpredis” redis extension for php gets installed. Even if you do not want email, you must at least issue a command like so

sudo pecl install redis

to complete the (php)redis installation. Along with the following “if running PHP?” section of the guide.

I have no idea what part the “php-apcu” package plays, but we do not usually install that and we have no problems without it. The “redis-server” package was already installed if “ping pong” worked so that played no part in the fix. The crucial part for you was installing the “php-redis” package and restarting Apache2.

We do not recommend using the php-redis package via the apt-get package manager as it is way too old (v2.2.5). That’s why the phpredis extension is installed via PECL in the guide.

Ideally you should uninstall it via apt-get

sudo apt-get purge php-redis
sudo apt-get clean

and install it via PECL as described above.

If you look at the “redis” entry in the php modules section of the admin page (right at the bottom in php not the redis section) you will see that is most likely currently v2.2.5 and after successfully changing it should say something like v3.1.4.

For clarity “phpredis” is the bridge between PHP and Redis, it goes under many similar names, in the apt-get repo’s it’s called “php-redis” and within PECL and PHP is is just called “Redis” but to be clear, it is not the “Redis” database itself, it is just a small PHP extension module.

I’m getting the exact same error, Ubuntu 16.04 - Synology VM, and I have installed redis using pecl during install.

If I reinstall redis using “sudo pecl install redis”, I get this error message:

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/20151012/redis.so’ - /usr/lib/php/20151012/redis.so: cannot open shared object file: No such file or directory in Unknown on line 0

I can confirm that Bruce’s hack cures the problem… or maybe not, sync module connects OK to emoncms.org, but no data is downloaded and feed date is pushed back to 1.jan 1970.

Emoncms log:

2018-05-02 19:58:54.478|WARN|sync_model.php|remote save
2018-05-02 19:58:54.757|WARN|sync_model.php|{“success”:true,“userid”:…

Did you get any error messages when installing?

Did you add the files and enable the extension after using PECL?

To my knowledge Ubuntu 16.04 uses php7, support for php7 doesn’t start in phpredis until v3.0.0 and the debian repositories version of php-redis is v2.2.5 (last time I checked), so whilst it might appear to work using v2.2.5 with php7, it might not be 100%.

For the record, I’ve just checked a Debian Stretch on amd64 instance running php7 with the redis extension installed via PECL and that has the file you appear to be missing

[email protected]:~$ ls -la /usr/lib/php/20151012/redis.so
-rw-r--r-- 1 root root 1809640 Jan 17 09:34 /usr/lib/php/20151012/redis.so

(see the Php-Redis 3.1.1? discussion for some insight to the versions, package managers and install methods).

What I meant to write was that I followed the guide in emoncms/LinuxInstall.md at master · emoncms/emoncms · GitHub more or less to the letter, and opted to install redis

sudo pecl install swift/swift redis

I did not pay attention to error messages at that point, but most probably it was the same as when I tried to reinstall. I have a clone of the fresh Ubuntu install, so I could test it if you need the information.

Unfortunately, my Linux skills are very basic. I’ll have a look at the post you suggest and see if I can pick up some idea to try out

But did you include the next bit?

If running PHP7: Add pecl modules to php7 config

    printf "extension=redis.so" | sudo tee /etc/php/7.0/mods-available/redis.ini 1>&2
    sudo phpenmod redis

(assuming you are installing php7, otherwise it would be the “If running PHP5” section instead)

again you must check the result/reply/confirmation for errors, you are using a non-standard arrangement so you need to be (even more) vigilant as the path is less well trodden and perhaps more likely to unearth peculiarities that other users may not experience with “vanilla” installs.

Yes, I did the php7 install and I did include that bit also. There were no error messages.

I’ll do the emoncms install again and doublecheck the output.

This is the output when trying to install redis, seems there is a file missing:

[email protected]:~$ sudo pecl install swift/swift redis
downloading Swift-5.1.0.tgz ...
Starting to download Swift-5.1.0.tgz (113,740 bytes)
.........................done: 113,740 bytes
downloading redis-4.0.2.tgz ...
Starting to download redis-4.0.2.tgz (212,617 bytes)
...done: 212,617 bytes
install ok: channel://pear.swiftmailer.org/Swift-5.1.0
24 source files, building
running: phpize
Configuring for:
PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012
enable igbinary serializer support? [no] : y
enable lzf compression support? [no] : y
building in /tmp/pear/temp/pear-build-rootlb7MEv/redis-4.0.2
running: /tmp/pear/temp/redis/configure --with-php-config=/usr/bin/php-config --enable-redis-igbinary=y --enable-redis-lzf=y
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
checking for PHP extension directory... /usr/lib/php/20151012
checking for PHP installed headers prefix... /usr/include/php/20151012
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking whether to enable redis support... yes, shared
checking whether to enable sessions... yes
checking whether to enable igbinary serializer support... y
checking whether to enable lzf compression... y
checking use system liblzf... no
checking for igbinary includes... configure: error: Cannot find igbinary.h
ERROR: `/tmp/pear/temp/redis/configure --with-php-config=/usr/bin/php-config --enable-redis-igbinary=y --enable-redis-lzf=y' failed

Why on both questions have you chosen to say yes when the default suggestion was “no”?

enable igbinary serializer support? [no] : y
enable lzf compression support? [no] : y

the file that is reported as missing is related to the first of those questions.

Try again, but this time try accepting the suggestions, unless you have good reason to do other wise and know what that entails or might need in the way of additional libs etc.

[edit] Oh and by the way, the command you need is just

sudo pecl install redis

the original command is to install 2 packages and “swift/swift” doesn’t need reinstalling each time whilst trying to sort phpredis out.

You should find that (php-)redis installs ok without uninstalling as it aborted, but if needed you can remove it first and then reinstall without having to start a fresh.

sudo pecl uninstall redis
sudo pecl install redis

Actually I did try the “No” option, or rather I thought I tried it. Looking through the output again, I realize that I put in an “n” in place of just hitting enter.

enable igbinary serializer support? [no] : n
enable lzf compression support? [no] :

Tried again to just hit enter, big fat fingers, and now it seems to install correctly. Will try it out when I get home from work.

How do I check for sure if my redis is installed correctly and working.

When I look at the phpinfo on the Apache server, under the redis section I see.


Redis Support
Redis Version
Available serializers
php, igbinary
Available compression

Perhaps @Lykke can confirm what he see’s once he has got it installed.

I do not have v4.0.1 installed yet to test and I have just found a note in the changelogs stating there are “breaking changes” in post v4 versions, I do not know if they affect us or how to test for them so I have opened an issue on emoncms that hopefully @TrystanLea or @nchaveiro might be able to answer.

I cannot say yet whether v4 is a problem of if emoncms requires change, but worse case scenario I guess is that you may need to use an earlier version if there is a problem or until we are sure it’s ok. Eg

sudo pecl uninstall redis
sudo pecl install redis-3.1.6
1 Like

Finished installing redis (4.02). Like the installer suggested, I added “extension=redis.so” to php.ini in the apache2 folder (correct folder?). No errors.

Finished the emoncms and the sync module install. Only install issues I encountered was rw permissions and incorrect paths. After emoncms bootup and update, sync connects OK to emoncms.org and the sync-feed list is populated. On pressing “download”, the remote feed shows up in the local feed list, but no data is downloaded.

Emoncms reports Redis 3.06

Anything I should test or try before following Pauls advice to roll back redis to 3.1.6 ?

Did you install the service runner required by the sync module?
Installation notes can be found at the bottom here: GitHub - emoncms/sync: In development: Download or upload emoncms feed data between local and remote emoncms server's

You’ve lost me a bit there, the guide in the emoncms repo is complete, we do not edit php.ini as a rule. The correct way is to use phpenmod top create symlinks in the necessary places to allow php to dynamically create it’s settings.

Aside from installing the Debian packages for php-pear and php-dev etc included in the main package list, installing the redis extension consists of the following 4 steps

  1. Updating the PECL index channel with sudo pecl channel-update pecl.php.net
  2. Install the redis package with sudo pecl install redis (or maybe a specific version)
  3. Make that extension “available” using printf "extension=redis.so" | sudo tee /etc/php/7.0/mods-available/redis.ini 1>&2 to add a file in “mods-available”
  4. Enable the extension with sudo phpenmod redis

at that point you should be done!

If there are any further steps required due to unusual paths etc because of the environment you are installing to I’m afraid I do not know about those.

running pecl info redis to tell you what version phpredis is installed ie available to enable.

running php -m will tell you what modules are enabled, “redis” should be hopefully be listed.

from the local machine you should also be able to navigate to http://myserver/emoncms/php-info.php to see a fair bit of info and at the end there should be a “redis” section that tells you about the phpredis extension.

And also if you look at the last section on the admin page there should be a “redis” entry with version number in there too if it’s successfully enabled, installed but not enabled modules are not listed there.

This is not to be confused with the Redis server section on the admin page which is the database application itself, not the php extension, that is what I believe you are looking at when you say “Emoncms reports Redis 3.06” as you have already said you’ve installed v4.0.2 and mentioned “rolling back to 3.1.6” which you cannot do if you are on 3.0.6.

Here is a “System information” dump that I have just pinched from a recent post by @Paul

Server Information
Emoncms Version 9.8.29 : 2018.05.01
Modules Administration : App v1.1.0 : Dashboard v1.1.1 : EventProcesses : Feed : Input : CoreProcess : Schedule : Time : User : Visualisation
Server OS Linux 4.9.59-v7+
Host raspberrypi raspberrypi (
Date 2018-05-03 15:43:33 BST
Uptime 15:43:33 up 6 min, 3 users, load average: 0.45, 0.98, 0.62
HTTP Server Apache/2.4.25 (Raspbian) HTTP/1.1 CGI/1.1 443
MySQL Version 5.5.5-10.1.23-MariaDB-9+deb9u1
Host localhost (
Date 2018-05-03 15:43:33 (UTC 01:00‌​)
Stats Uptime: 394 Threads: 3 Questions: 21 Slow queries: 0 Opens: 19 Flush tables: 1 Open tables: 13 Queries per second avg: 0.053
Redis Version 3.2.6
Host localhost:6379 (
Size 130 keys (701.08K)
Uptime 0 days
MQTT Version 1.4.10
Host localhost:1883 (
Pi CPU Temp 54.23°C
Memory RAM Used: 39.82% Total: 875.78 MB Used: 348.72 MB Free: 527.06 MB
Swap Used: 0.00% Total: 100 MB Used: 0 B Free: 100 MB
Disk Mount Stats
/ Used: 67.00% Total: 6.86 GB Used: 4.6 GB Free: 1.93 GB
/boot Used: 50.62% Total: 41.15 MB Used: 20.83 MB Free: 20.32 MB
/mnt/data Used: 17.82% Total: 458.49 GB Used: 81.71 GB Free: 376.78 GB
PHP Version 7.0.27-0+deb9u1 (Zend Version 3.0.0)
Modules apache2handler : bz2 v7.0.27-0+deb9u1 : calendar v7.0.27-0+deb9u1 : Core v7.0.27-0+deb9u1 : ctype v7.0.27-0+deb9u1 : curl v7.0.27-0+deb9u1 : date v7.0.27-0+deb9u1 : dio v0.1.0 : dom v20031129 : exif v7.0.27-0+deb9u1 : fileinfo v1.0.5 : filter v7.0.27-0+deb9u1 : ftp v7.0.27-0+deb9u1 : gd v7.0.27-0+deb9u1 : gettext v7.0.27-0+deb9u1 : hash v1.0 : iconv v7.0.27-0+deb9u1 : json v1.4.0 : libxml v7.0.27-0+deb9u1 : mbstring v7.0.27-0+deb9u1 : mcrypt v7.0.27-0+deb9u1 : mosquitto v0.4.0 : mysqli v7.0.27-0+deb9u1 : mysqlnd : openssl v7.0.27-0+deb9u1 : pcre v7.0.27-0+deb9u1 : PDO v7.0.27-0+deb9u1 : pdo_mysql v7.0.27-0+deb9u1 : Phar v2.0.2 : posix v7.0.27-0+deb9u1 : readline v7.0.27-0+deb9u1 : redis v3.1.6 : Reflection v7.0.27-0+deb9u1 : session v7.0.27-0+deb9u1 : shmop v7.0.27-0+deb9u1 : SimpleXML v7.0.27-0+deb9u1 : sockets v7.0.27-0+deb9u1 : SPL v7.0.27-0+deb9u1 : standard v7.0.27-0+deb9u1 : sysvmsg v7.0.27-0+deb9u1 : sysvsem v7.0.27-0+deb9u1 : sysvshm v7.0.27-0+deb9u1 : tokenizer v7.0.27-0+deb9u1 : wddx v7.0.27-0+deb9u1 : xml v7.0.27-0+deb9u1 : xmlreader v7.0.27-0+deb9u1 : xmlwriter v7.0.27-0+deb9u1 : xsl v7.0.27-0+deb9u1 : Zend OPcache v7.0.27-0+deb9u1 : zip v1.13.5 : zlib v7.0.27-0+deb9u1 :

In there you will see the Redis server is in it’s own section and at version 3.2.6 and in the last “PHP - Modules” section, the Redis extension for PHP is listed as “redis v3.1.6” (listed means it’s enabled).

As for the Sync module, I think we should confirm redis is ok before attempting the sync module, there are many other bits to that process that could stand between a button press and a succesful download, not just redis. It needs to create a temp flag file, there needs to be a cronjob running to pick up on that flag and run a script which has to reach the server and be able to write it locally so there are many permissions and paths that may need checking if this is not a straightforward emonPi/emonSD.

So are you able to confirm redis is both installed and enabled using one or more of the above methods?

Since this is a fresh install and on a more exotic OS/machine and you are trying to use some very new software that hasn’t been widely tested, perhaps you should roll-back to 3.1.6, there are too many unknowns, if the module is enabled and the sync module still doesn’t work we don’t know if it’s due to a version 4.0.2 issue or not, at least with 3.1.6 we know that should work ok and reduces the unknowns to just an uncommon environment and an untested emoncms module.

Didn’t know the emoncms site had its own phpinfo page. I wrote my own!

Anyway, I have everything as per Paul’s checklist. So I’ll assume my redis is set up.

Just for info, on my Adminstration page Redis (server) is at 3.0.6 and PHP redis is at 4.0.1

Everything appears to work fine. But I haven’t used sync.

So your redis server is behind our normal version and your redis extension is ahead of our norm (ie server 3.2.6 and extension 3.1.6) I have no idea how or if that combo will work so please let us know how you get on in due course.

Thanks you for the comprehensive answer!

Emoncms and PECL reports redis 4.02 in the PHP section. PHP confirm redis. I’ll try the roll back

3.1.6 install OK. What do you make of this?:

Build process completed successfully
Installing ‘/usr/lib/php/20151012/redis.so’
install ok: channel://pecl.php.net/redis-4.0.2
configuration option “php_ini” is not set to php.ini location
You should add “extension=redis.so” to php.ini