OpenEnergyMonitor Community

Installing emonCMS on Ubuntu

I can’t get emonCMS installed on Ubuntu and the forum will not allow me to post links to explain the problem.

Hope this screen shot can be seen.

It should do now - I’ve upped your permissions by a notch.

@simmonslr, I also had problems installing emoncms on Ubuntu. With help of @borpin I managed to install emoncms. I’m just finished to install everything from scratch again and I made some notes for myself. I’ll share them with you.

As you can read on the emoncms github page, it has lots of possible ways to install: a emonSD SD-card image, Debian build script, Docker (experimental), …

Just to test emoncms on a Lubuntu 20.04.2 LTS laptop, I will use the Debian build script as a source for my installation. This script can be used to build a fully fledged emonCMS installation on debian based operating systems, including: installation of LAMP server and related packages, redis, MQTT, emonCMS core, emonCMS modules, and if applicable, emonhub & RaspberryPi support for serial port, and WiFi access point.

The Debian build script actually is a series of scripts that install each required component and I look at the individual scripts and adapt them – if needed – to my personal situation. It has the advantage that I can see more what is going on and skip things I don’t need. I has the disadvantage that it does not guarantee to be a complete solution (some folders may not be created for instance) and that debugging later on might be more difficult as I might have a slightly different setup than the official build script.

The steps will almost certainly work on Ubuntu 20.04 LTS. I wouldn’t recommend a non-LTS (Long Term Support) version like 20.10, but still it might work.


This section is used to make the filepaths work. You can copy-paste the code in the terminal (ctrl + alt + t) or copy-paste it in a script to execute.

# variables that are used in different scripts
# make sure everything is up-to-date
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get clean
# install git-core so that other source code can be downloaded from git later on
sudo apt-get install -y git-core
# default filepaths
sudo mkdir $openenergymonitor_dir
sudo mkdir $emoncms_dir
# set permissions so that current user doesn’t need sudo
sudo chown $user $openenergymonitor_dir
sudo chown $user $emoncms_dir
# get some files, although I will not use all of them
cd $openenergymonitor_dir
git clone
cd $openenergymonitor_dir/EmonScripts
git checkout stable
cd $openenergymonitor_dir/EmonScripts/install


I will only use as a reference to know what to do, but I will not execute it. It is installed on a regular laptop and not on a raspberrypi, so I will edit emonsd.config.ini to change user, hostname and set emonSD_pi_env to 0. Then I can do:

cp emonsd.config.ini config.ini

I don’t have a emonpiLCD or rfm69pi and I don’t think the wifi-part applies, so I don’t execute it.

# Required for emonpiLCD, wifi, rfm69pi firmware (review)
# if [ ! -d $openenergymonitor_dir/data ]; then mkdir $openenergymonitor_dir/data; fi

Install some more software, although on my system everything was already installed:

sudo apt-get install -y git build-essential python3-pip python3-dev


Emoncms is web application and needs a web server to be able to work.

I had a look at the script. As far as I understand gettext is necessary for internationalization and localization. I dont know why CustumLog needs to be commented out, but still I do it.


Unfortunately I had an error:

Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.

I checked the status and apparently /var/log/emoncms/ doesn’t exist and on further investigation also /var/www/emoncms doesn’t exist. But that will be fixed later on. Maybe it would be an idea for the authors @borpin or @TrystanLea to make sure the /var/log/emoncms/ and /var/www/emoncms are already okay in this step, to avoid confusion. And it is always nice to already be able to test something, namely see that http://localhost already works :-).


Emoncms uses a database to eg. store its settings. The used MySQL user, password and database is as defiened in emonsd.config.ini and was copied to config.ini.



PHP is a powerful server side programming language, mostly used in combination with Apache and Mysql.



Redis (Remote Dictionary Server) is an in-memory data structure store, used as a distributed, in-memory key–value database, cache and message broker, with optional durability. As far as I understand, emoncms uses it, to avoid file system writes as much as possible. That’s because if the install is on an SD card, the SD card doesn’t like all that writing.



The Message Queuing Telemetry Transport (MQTT) is a lightweight, publish-subscribe network protocol that transports messages between devices. OEM use it as one way of passing data between different hardware devices and software components within the OpenEnergyMonitor ecosystem. The technical details are at MQTT - Guide | OpenEnergyMonitor.

Eclipse Mosquitto is an open source message broker that implements the MQTT protocol. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.


Emoncms core

The core includes user, inputs, input processing, feeds & visualisations functionality. Like I have written before, I think it would be better to move some of the commands to the installation of apache?


On testing http://localhost/ I get a

Fatal error: Uncaught Error: Class 'Redis' not found in /var/www/emoncms/index.php:36 Stack trace: #0 {main} thrown in /var/www/emoncms/index.php on line 36

After the next section, the error dissapears. I guess the database gets reloaded in the next step, so that Redis is recognized.

Emoncms modules

Emoncms is designed as a modular extendable application (see emoncms-modules). The script installs dashboard, device, app, graph, postprocess, demandshaper, backup, sync, usefulscripts and then updates the database.

bash ./

Register a user

At this moment you can already go to http://localhost/ and register a user.


Emonhub consists of a series of interfacers that can read/subscribe or send/publish data to and from a multitude of services. It might be that you don’t need it. I personally need it to be able to read my modbus enabled kWh meters and store their values in emoncms. Other might need it to read data received over serial from either the EmonPi board or the RFM12/69Pi adapter board.


If I go to http://localhost/admin/view, the emonhub service is listed as ‘Inactive Dead’. I also got an error in my terminal:

Failed to restart emonhub.service: Unit var-log.mount not found.
- Service ActiveState=inactive

Luckily @borpin found a solution! The settings of the emonhub.service are at /etc/systemd/system/emonhub.service and I could have commented out the var-log.mount over there. But this would prevent git updates. A better way is to create a drop in (hopefully this drop in isn’t needed anymore in a future script, so that the install can be a bit shorter :slight_smile: ).

sudo systemctl edit emonhub.service

put the following in and save


You then need to reload the daemon:

sudo systemctl daemon-reload

Then restart the computer. Logging in at http://localhost/admin/view and you should see the service emonhub ‘Active Running’.

@simmonslr, I hope you can manage to install with these steps?

1 Like

Thanks, that helped. That was the direction I was headed, but you saved me work. It’s installed and running now.

I’m glad I could be of some help. FYI: on my system, the module demandshaper is ‘Inactive Dead’. But as I don’t need that module, I didn’t invest time to fix it.