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.

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.

Emoncms Graph

Why not follow @mylesagray on Twitter ↗ for more like this!