Installing emoncms - redis problem on openSUSE system

I’m trying to install emoncms on my openSUSE system, so I can experiment with it more easily than on my production pi. But I’m getting an error I don’t understand. When I go to http://localhost/emoncms/ I see:

    settings.php file error

    redis enabled but not installed, check setting: redis_enabled

    To fix, check that the settings are set in settings.php or try re-creating your settings.php file from default.settings.php template

Now it’s a very misleading error, because redis is installed and running:

$ systemctl status [email protected][email protected] - Redis
   Loaded: loaded (/usr/lib/systemd/system/[email protected]; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/[email protected]
   Active: active (running) since Mon 2019-03-04 20:02:01 GMT; 24h ago
 Main PID: 14244 (redis-server)
    Tasks: 4 (limit: 4915)
   CGroup: /system.slice/system-redis.slice/[email protected]
           └─14244 /usr/sbin/redis-server

and the suggested fix is exactly the opposite of what I need. I want to fix the problem, not make it go away by stopping redis!

Eventually I figured that the problem it is reporting is an apparent problem with the PHP redis subsystem, but php_info.php shows:

PHP Version => 7.2.5


Redis Support => enabled
Redis Version => 4.0.2
Available serializers => php

So I’m a bit stumped. I know next to nothing about PHP and very little about redis.

I can’t follow the published instructions exactly, since openSUSE uses a different system to debian and derivatives. So if anybody can explain what I should be checking in simple words …

What is in your EmonCMS settings.php for redis?
It should be in /var/www/html/emoncms.

This is what mine looks like:

//2 #### Redis
    $redis_enabled = true;
    $redis_server = array( 'host'   => 'localhost',
                           'port'   => 6379,
                           'auth'   => '',
                           'prefix' => '');

Well, it’s actually in /srv/www/htdocs/emoncms/ but I know what you mean :slight_smile:

I have:

$redis_enabled = true;
$redis_server = array( 'host'   => 'localhost',
                       'port'   => 6379,
                       'auth'   => '',
                       'dbnum'   => '',
                       'prefix' => 'emoncms');

I changed enabled from false to true but I haven’t touched anything else. I’m curious why the prefix is different and what effect that might have? Oh, and why there’s a dbnum key in mine but not yours?

The prefix on an EmonPi is different than on any other self install - it makes no difference (well, now - it did cause a few issues recently though!)

So your configuration file for host and port matches what is actually running so that’s step 1 out of the way.

Next step is to probably test redis from the command line… you’ll need to install redis-cli for that using whatever you need to use on openSUSE. Then try this:

$ redis-cli> lpush test "hello"
(integer) 1> lpop test
"hello"> exit

If that all works, we can confirm that redis is actually working and rule that out.

Yes, that works. I had run redis-cli PING before.

Ok, I just found this post indicating that PHP redis >v4 breaks things… it was from a while ago, but the resolution was to downgrade to a v3.x version:

Hmm, that was quite a while ago. I run the stable version of openSUSE, so I’m not exactly running bleeding edge stuff. So I’m surprised it breaks emoncms. Is a fix being worked on, do you know?

I generally prefer to stick with the distro-provided versions of software because that causes less breakages. I note that I don’t have ‘pecl’ installed and it isn’t listed when I search the repositories. I think I need that if I were to change php-redis version. Is it possible to load more than one version of packages in PHP similarly to perlbrew or whatever?

Also, I don’t quite understand the connection between version and error? The error message is generated by process_settings.php very simply:

if (!isset($redis_enabled)) $redis_enabled = false;
if ($redis_enabled) {
    if (!class_exists('Redis')) $error_out .= "<p>redis enabled but not installed, check setting: redis_enabled</p>";

I don’t understand how that would generate the error because of a version 4.0.2 redis extension? But as I say, I know next to nothing about PHP or redis.

Clearly class_exists('Redis') is failing, suggesting that the php module isn’t recognised.
Is that related to v4 vs v3? I have no idea.

Its a fairly simple test to downgrade it to find out! You can always go back to your existing version if it doesn’t fix anything - what’s to lose?

How? (and here are some more characters)

pecl is generally part of the php-pear package, can you install that?

How did you install the PHP Redis extension? emoncms/ at master · emoncms/emoncms · GitHub

By installing php7-redis from the openSUSE repositories.

Pretty sure there is something weird about that. I think @pb66 is the expert on this.

Look at Updating system libraries used by emoncms as well. It starts off talking about Mosquitto, but then talks about redis. Also search on pecl in the community.

Best way is to follow the self install instructions. they are there for a reason.

[edit] this post probably most relevant Updating system libraries used by emoncms - #20 by pb66

Yes, there’s a php7-pear package. Can I install multiple versions of the redis extension - e.g. one locally to test this - without messing up the system installed one?

As I said, openSUSE uses different commands.

What does

pecl list-upgrades



What is different? pecl seems to be available?

Turns out pecl isn’t in it though :frowning: It’s in php7-devel so:

$ pecl list-upgrades
WARNING: channel "" has updated its protocols, use "pecl channel-update" to update
Channel No upgrades available

As I said, I installed the extension from the repo. The data structures in /etc/php are completely different and I shouldn’t be poking things in there anyway.

I still don’t understand why that error appears, and nobody has yet pointed me to however pecl manages multiple versions of extensions.

Which is why the instructions say to install dev (devl in openSUSE I gather).

I’d suggest uninstalling the php7-redis package version, add in the pecl version and then enable the extenstion (phpenmod usually).

You will see the command pecl channel-update is suggested in the install instructions.

I think they use different packages too.

There are different redis extensions for php and they are not all the same. The one used by emoncms is “phpredis” and another that i’m aware of is “predis”. I have no idea what it is that the opebSUSE repos are serving up, there isn’t much to go on at the openSUSE site (openSUSE Software).

“phpredis” is available from various places, direct from github, from PECL and from the Debian repos. We use the PECL route as the debian repos were always too far behind and building from source (github) was over complex.

When installing “phpredis” via PECL (known as just “redis” on PECL) there are minor additional steps, ie it needs to be enabled. The error you are seeing is because emoncms cannot create a class, that is because either the extension is not installed AND enabled, or redis-server is not installed AND running AND configured in settings.php, we can see your settings are right and that the redis-server is running so it looks likely to be the extension. But installing to openSUSE is not a well trodden path so potentially nothing is certain.

I do not know anything about openSUSE but I suspect installing PECL and then “redis” (aka phpredis) as per the emoncms guide (amended for any openSUSE differences) might be the way to go.

Whilst I’m writing I can see you’ve done just that so . . .

That warning is standard and all you need to do is follow the instruction and run pecl channel-update (using sudo if required perhaps?)

The data structures may be different, but you will still have a folder that lists all available php extensions and you will probably need to create a file in that location and the enable the extension using whatever method openSUSE uses, I can only tell you how it’s done in Debian based distros. (It maybe the same and use phpenmod too? I really have no idea)

The version is controlled by the command issued to install via PECL, pecl install redis will give you the latest stable version where as pecl install redis-4.0.2 will install v4.0.2 (for example).