Community
OpenEnergyMonitor

Community

Installing emoncms - redis problem


(Dave Howorth) #41

I gave my redis-server version earlier. It is 4.0.10. phpredis is 4.0.1

[edit] I’m using Leap 15.0, which is the stable version of openSUSE.


(Dave Howorth) #42

The lines that appear to me to depend on the name are:

./.travis.yml:    - sudo apt-get install php-pear php$TRAVIS_PHP_VERSION-dev redis-server build-essential g++ wget -y
./Modules/admin/admin_main_view.php:    $services['redis-server'] = getServiceStatus('redis-server.service');
./scripts/logger/rc.local:for i in "emoncms.log" "mysql.log" "redis/redis-server.log" "mysql/error.log" ; do touch /var/log/"$i"; done
./scripts/logger/rc.local:for i in "emoncms.log" "mysql.log" "redis/redis-server.log" "mysql/error.log" "apache2" ; do ""chmod 666"" /var/log/"$i"; done
./scripts/logger/rc.local:/etc/init.d/redis-server restart
./scripts/mqtt_input.service:After=mosquitto.service mysql.service redis-server.service
./scripts/services/emoncms_mqtt/emoncms_mqtt.service:Wants=mosquitto.service mysql.service redis-server.service
./scripts/services/emoncms_mqtt/emoncms_mqtt.service:After=mosquitto.service mysql.service redis-server.service
./scripts/services/feedwriter/feedwriter.service:Wants=mysql.service redis-server.service
./scripts/services/feedwriter/feedwriter.service:After=mysql.service redis-server.service
./scripts/services/service-runner/service-runner.service:Wants=redis-server.service
./scripts/services/service-runner/service-runner.service:After=redis-server.service

(Paul) #43

I think you need to restart apache2 after enabling mod_rewrite, not just a reload.

[Edit] also depending on how you have set up your virtual host, you’ll possibly need a AllowOverride All rule in there somewhere.


(Dave Howorth) #44

I believe reload is equivalent to a graceful restart. That’s what the log says:

AH00171: Graceful restart requested, doing restart

It certainly made redis available, so I’m not sure why the login is failing now. There’s nothing in the apache log and emoncms.log is empty.

[edit] There’s no virtual host. It’s the default server.
[edit2] I didn’t need to enable mod_rewrite; it’s always been enabled and it shows in phpinfo


(Greebo) #45

All of those .service files and the rc.local file relate to external services that cannot use “variable” names - they are not part of the emonCMS website so have nothing to do with any of your issues (as you already know by now anyway)
The Travis file is related to auto build testing on GitHub, also unrelated to the emonCMS website.

The only file that is part of the emonCMS website is the admin_main_view.php and that is the “service checker” as per @pb66’s message above that will show an incorrect “service status” for redis-server on the admin page but otherwise has no impact on the use of redis.


(Paul) #46

The default virtual host rules will be defined in apache2.conf then perhaps?

It was the norm for that file to be edited to allow rewrites server wide, but that is frowned upon and should be overridden with a virtual host.

Again, no idea about openSUSE but the preferred way with Debian etc is to create a new emoncms.conf virtual host and then disable the 000-default.conf site and enable the emoncms.conf site instead with the rules required for emoncms. You could look at the docs in the emoncms repo for pointers.

[Edit] I would still try restarting apache2 before delving in too deep, just in case, even if just to rule it out.


(Dave Howorth) #47

Again, I am using the default server configured as in “default-server.conf . . . . . . . . . set up the default server that replies to non-virtual-host requests”. There are NO virtual hosts.

I already said and posted the log entry that a reload does a graceful restart.

[edit] I think the problem may be that you have a bunch of rules in a .htaccess file. openSUSE doesn’t generally use .htaccess files (I don’t remember why, I think it’s something to do with security risks). Instead it uses specific conf files in /etc/apache2/conf.d/ so I’ll see how easy it is to copy the .htaccess to that directory and/or perhaps make an exception to the standard rule that forbids them for the emoncms directory.

[edit2] OK so I copied the .htaccess to /etc/apache2/conf.d/emoncms and restarted apache.

First problem - you have obsolete directives at the end of the file Order, Deny and Allow have been replaced by Require:

    # protect phpinfo, only allow localhost and local network access
    <Files php-info.php>
    #       djh replace obsolete Order etc directives with Require
    #       Order Deny,Allow
    #       Deny from all
    #       Allow from 10
    #       Allow from 172
    #       Allow from 192
            Require ip 10 172 192.168
    </Files>

I also wrapped a

<Directory /srv/www/htdocs/emoncms>

around everything but now I’m getting - second problem -

# Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
Error 403

I’m stopping for lunch, so if anybody has any ideas I’d love to hear them :grin:

[edit3] I’ve now had lunch and added a FollowSymLinks option to the apache conf file and that’s got around the 403 error. Now I see:

Username does not exist

when I try to login. How and where does emoncms store its usernames and passwords? google isn’t helping so far.


(Brian Orpin) #48

I’d certainly be rebooting the whole thing. I know the theory says you don’t need to, but IME you often do.


(Dave Howorth) #49

There’s absolutely no way I would consider rebooting the machine, if that’s what you mean.

But anyway, I’m past the apache problems now. If you look at the last part of my message above, you can see the current state. I suspect emoncms can’t access its database. Looking at the emoncms user in the mysql (actually mariadb) database, it doesn’t seem to have any permissions. I’ll check what and how it’s supposed to have if I can find the instructions again.


(Dave Howorth) #50

OK, so I found the appropriate table in the emoncms database and its empty. Which is what made me think emoncms couldn’t access the database, but I found its privileges in the db table so that’s OK. So then I thought maybe the database is empty because I’ve never registered? So I decided to register instead of login. When I did I got this error:

Fatal error: Uncaught Error: Call to undefined function ctype_alnum() in /srv/www/htdocs/emoncms/Modules/user/user_model.php:229
Stack trace:
#0 /srv/www/htdocs/emoncms/Modules/user/user_controller.php(51): User->register('dhoworth', 'password', 'my-opensuse-emo...')
#1 /srv/www/htdocs/emoncms/core.php(64): user_controller()
#2 /srv/www/htdocs/emoncms/index.php(210): controller('user')
#3 {main} thrown in /srv/www/htdocs/emoncms/Modules/user/user_model.php on line 229

Does anybody recognize these symptoms before I go crawling through yet more code?

[edit] PS I just created issue 1220 for the obsolete directives in the htaccess file.


(Dave Howorth) #51

They don’t have anything to do with my getting to the point of being able to log in, no. But they will affect how the system works, I believe. For example, feedwriter should be run. So they will cause me problems.

And you can pass variables to systemd unit files, using environment variables. So there’s no reason for writing code with hardwired names that can change from system to system. Doing so simply breaks portability. Denying it’s a problem is head-in-the-sand AFAICT.


(Greebo) #52

It is expected that if you’re doing a self install, you know enough to fix that stuff. To be fair to the EmonCMS folks, as far as I’m aware you are the first person to ever find a redis service NOT called redis-server and there’s people using a few different distro’s with self installs.

If you have a better idea on how it should be treated that works better in all cases and is more easily supported, fix it and submit a PR on GitHub.


(Dave Howorth) #53

So nobody answered so I went digging. Apparently ctype is an extension and openSUSE packs extensions separately. Now I’ve installed that, I can login. Again, IMHO, best practice is to check dependencies at install time and report them.