Blah, Cloud.

Adventures in architectures

  • Twitter
  • GitHub
  • Home
  • Blog
  • Kubernetes on vSphere
  • Multi-tenant IaaS Networking
  • Me
    • About
    • CV
    • Contact
Home » Blog » Arduino/Hacking » How to: Run emoncms on NginX and PHP5-FPM

How to: Run emoncms on NginX and PHP5-FPM

12/11/2012 by Myles Gray 11 Comments

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.

enter image description here

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

Show some love:

  • Reddit
  • Twitter
  • Pocket
  • LinkedIn
  • Email
  • Telegram

Similar things I've written

Filed Under: Arduino/Hacking, Infrastructure Tagged With: Arduino, emoncms, NginX, PHP5-FPM

About Myles Gray

Hi! I'm Myles, and I'm a Dev Advocate at VMware. Focused primarily on content generation, product enablement and feedback from customers and field to engineering.

Comments

  1. ziga says

    22/02/2014 at 09:08

    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.

    Reply
    • Myles Gray says

      24/02/2014 at 13:29

      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.

      Reply
  2. George Constantine says

    27/07/2014 at 20:45

    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?

    Reply
    • Myles Gray says

      28/07/2014 at 11:42

      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?

      Reply
  3. Simsa says

    09/04/2015 at 02:36

    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

    Reply
    • Simsa says

      22/04/2015 at 08:11

      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?

      Reply
      • Simsa says

        03/05/2015 at 14:59

        It’s working now. The solution was to point the url in emonhub to the new name and port where nginx was listening.

        Reply
  4. Dennis says

    15/10/2018 at 14:57

    I get this

    nginx: [emerg] open() “/etc/nginx/sites-enabled/emoncms.conf” failed (13: Permission denied) in /etc/nginx/nginx.conf:336

    Reply
    • Myles Gray says

      15/10/2018 at 15:21

      Make sure the user NginX is running as has read permissions to read its config file directory

      Reply
      • Dennis says

        16/10/2018 at 13:11

        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

        Reply
        • Myles Gray says

          16/10/2018 at 18:32

          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

          Reply

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Myles Gray

Hi! I'm Myles, and I'm a Dev Advocate at VMware. Focused primarily on content generation, product enablement and feedback from customers and field to engineering. Read More…

Categories

Tags

active directory authentication CBT cisco datastore dell design esxi fortigate iscsi jumbo frame kubernetes lab linux load-balancing lun md3000i mtu networking NginX nic nsx openSUSE osx pxe readynas san sdelete serial teaming ubuntu vcenter vcloud director vcsa vexpert video VIRL vmdk vmfs vmware vsan vsphere vsphere 6 vsphere beta windows

Subscribe to Blog via Email

Copyright © 2021 · News Pro Theme on Genesis Framework · WordPress · Log in

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.