Skip to content

Instantly share code, notes, and snippets.

@mano8
Last active September 8, 2022 16:44
Show Gist options
  • Save mano8/d97c0e0df2eeba49cf48169a75f22310 to your computer and use it in GitHub Desktop.
Save mano8/d97c0e0df2eeba49cf48169a75f22310 to your computer and use it in GitHub Desktop.

Revisions

  1. mano8 revised this gist Sep 8, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions emoncms_nginx_conf.md
    Original file line number Diff line number Diff line change
    @@ -25,6 +25,9 @@ And Install needed emoncms Modules :
    ```# cd /opt/emoncms/Modules```
    ```# git clone --branch stable https://github.com/emoncms/graph```

    In case you use redis server with emoncms, be sure to install php-redis:
    ```# sudo apt-get update```
    ```# sudo apt-get install php-redis```

    ## Nginx configuration :
    [see here for more info](https://openenergymonitor.github.io/forum-archive/node/5308.html).
  2. mano8 revised this gist Sep 8, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions emoncms_nginx_conf.md
    Original file line number Diff line number Diff line change
    @@ -73,6 +73,8 @@ Ensure there is no errors on nginx configuration files:
    Update php.ini with:
    ```# sudo nano /etc/php/7.4/fpm/php.ini ```
    And set ```cgi.fix_pathinfo = 0```
    Reload php service :
    ```# sudo systemctl reload php7.4-fpm ```

    Reload Nginx Configuration :
    ```# sudo systemctl reload nginx```
  3. mano8 created this gist Sep 8, 2022.
    89 changes: 89 additions & 0 deletions emoncms_nginx_conf.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,89 @@
    # Emoncms installlation (debian11/nginx)

    Above is the nginx configuration to run emoncms on debian 11 with php7.4.

    ## Prepare emoncms installation
    Create the above paths needed from emoncms :
    ```
    # sudo mkdir /var/opt/emoncms/
    # sudo mkdir /var/opt/emoncms/phptimeseries/
    # sudo mkdir /var/opt/emoncms/phpfina/
    # sudo chown -R www-data:www-data /var/opt/emoncms
    # sudo mkdir /var/log/emoncms
    # sudo touch /var/log/emoncms/emoncms.log
    # sudo chown -R www-data:www-data /var/log/emoncms
    # sudo chmod 666 /var/log/emoncms/emoncms.log
    # sudo mkdir /var/www/emoncms
    # sudo chown -R www-data:www-data /var/www/emoncms
    # sudo ln -s /var/www/emoncms /opt/
    # sudo chown -R $USER:$USER /opt/emoncms
    ```
    Now we can clone emoncms repository :
    ```# cd /opt/emoncms```
    ```# git clone --branch stable https://github.com/emoncms/emoncms.git emoncms```
    And Install needed emoncms Modules :
    ```# cd /opt/emoncms/Modules```
    ```# git clone --branch stable https://github.com/emoncms/graph```


    ## Nginx configuration :
    [see here for more info](https://openenergymonitor.github.io/forum-archive/node/5308.html).
    To save on '''/etc/nginx/sites-available/emoncms''' file:
    ```
    server {
    listen 8080;
    server_name emoncms.local www.emoncms.local;
    root /var/www/emoncms;
    index index.php index.html index.htm;
    location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ /index.php?q=$uri&$args;
    #try_files $uri $uri/ =404;
    # Uncomment to enable naxsi on this location
    # include /etc/nginx/naxsi.rules
    #rewrite ^/(.*)$ /index.php?q=$1 last;
    }
    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
    expires 30d;
    root /var/www/emoncms;
    }
    location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    include fastcgi_params;
    #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
    location ~ /\.ht {
    deny all;
    }
    }
    ```
    and then, to activate it, run:
    ```# sudo ln -s /etc/nginx/sites-available/vemonitor /etc/nginx/sites-enabled/```
    Ensure there is no errors on nginx configuration files:
    ```# sudo nginx -t```

    Update php.ini with:
    ```# sudo nano /etc/php/7.4/fpm/php.ini ```
    And set ```cgi.fix_pathinfo = 0```

    Reload Nginx Configuration :
    ```# sudo systemctl reload nginx```

    ### Emoncms setting.php
    Copy the setting file:
    ```# cd /opt/emoncms```
    ```# copy example.settings.php settings.php```
    Edit settings :
    ```# nano settings.php```
    Add mysql credentials and if needed Redis and Mqtt settings.

    Now we can visit ```http://127.0.0.1:8080``` (if listen port not modified on emoncms nginx conf),
    and setup emoncms credentials.