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 redis@default
● [email protected] - Redis
Loaded: loaded (/usr/lib/systemd/system/[email protected]; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/[email protected]
└─limits.conf
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 127.0.0.1:6379
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
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 …
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
127.0.0.1:6379> lpush test "hello"
(integer) 1
127.0.0.1:6379> lpop test
"hello"
127.0.0.1:6379> exit
$
If that all works, we can confirm that redis is actually working and rule that out.
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.
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?
Turns out pecl isn’t in it though It’s in php7-devel so:
$ pecl list-upgrades
WARNING: channel "pear.php.net" has updated its protocols, use "pecl channel-update pear.php.net" to update
Channel pear.php.net: 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.
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 pear.php.net (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).