For those of you that don’t know, emoncms is a small cms that will accept inputs via GET requests for things like power meters, temp probes for measuring household power usage, PV panel, windmill etc power production levels.
DEMO **** To achieve this you need to use git to download the newest version of emoncms (the new more modularised version):
$ git clone git://github.com/emoncms/emoncms.git
Next step is to set up a mysql db:
$ mysql -u root -p
mysql> CREATE DATABASE emoncms;
mysql> exit
Next we are going to write and nginx config for emoncms I have hosted mine on https w/ SPDY however for simplicity this config is for http:
server {
listen 80;
server_name sub.domain.name;
location / {
root /path/to/your/emoncms;
index index.php;
rewrite ^/(.*)$ /index.php?q=$1 last;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
expires 30d;
root /path/to/your/emoncms;
}
location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(.*)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /path/to/your/emoncms$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
}
}
I’d like to highlight this line:
rewrite ^/(.*)$ /index.php?q=$1 last;
This is extremely important to make emoncms work, it rewrites the pretty URLs to reference them to the index file. Without this you will get “Invalid Username/Password” when you try to log in or register. cd to your emoncms folder and move the default settings file to make it active, then open it:
$ cd /var/www/emoncms/
$ mv default.settings.php settings.php
$ nano settings.php
Then change your DB settings like so:
/*
Database connection settings
*/
$username = "youruser";
$password = "yourpassword";
$server = "localhost";
$database = "emoncms";
Now restart NginX:
$ service nginx restart
If all is well you will be able to navigate to your URL, enter a username and password
then click Register, a bit counter-intuitive but there we are.
Why not follow @mylesagray on Twitter for more like this!
Hi I need help with setting up EmonCms with Nginx. Where should I write the write and nginx config for emoncms. I am hosting the EmonCms on my Pi.
Thanks for the answer.
The config lives in: /etc/nginx/sites-available/[youresitename.conf] then you need to symlink it to /etc/nginx/sites-enabled/[yoursitename.conf] and restart the nginx service.
Thank you! Your instructions worked. (I used a socket instead of a port for php-fpm).
Unfortunately, although the inputs get updated by my arduino, the “spanner” icon is non-responsive. Has this occurred to anyone else? Is it because of nginx?
George, haven’t looked at emoncms in a while – perhaps you have a newer version than I do but I don’t have any spanner icon?
Hi Myles,
thanks for your tutorial! I have just one problem the dial animation is not working with nginx. Do you have a hint for that?
Thanks, Simsa
I noticed that the problem is deeper :) The feedlist is inactive and it doesn’t show any values. With Apache2 it’s all working.
Anyone a clue how to fix this?
It’s working now. The solution was to point the url in emonhub to the new name and port where nginx was listening.
I get this
nginx: [emerg] open() “/etc/nginx/sites-enabled/emoncms.conf” failed (13: Permission denied) in /etc/nginx/nginx.conf:336
Make sure the user NginX is running as has read permissions to read its config file directory
must i create a user named NginX ? I dont get it
this is in the sites-enabled dir
I created a symlink in sites-available to sites-enabled
lrwxrwxrwx 1 root root 39 Oct 15 16:54 emoncms.conf -> /etc/nginx/sites-available/emoncms.conf
and chmod 777 on the sites-available
i don’t have a user NginX on my system
You need to chmod the /etc/nginx/nginx.conf file and make sure it is owned by the user the nginx daemon is running as