Skip to main content
Skip table of contents

EMX Local 4.0 Installation Guide - Ubuntu 24.04

Requirements

Energy monitoring systems produce a high volume of data. It is important that the server EMX will be deployed on is sized correctly for this type of workload. In particular, the application's performance is heavily dependent on access to sufficient memory and the use of high-speed disk.

General Guidelines

Monitoring Units

Gateways

Processor Cores

Memory (GB)

Disk Space (GB)

< 100

1 - 2

2

4 to 8

250

100 to 500

2 - 5

4

8 to 16

500

500 to 5,000

5 - 50

8

16 to 64

1000+

For deployments over 5,000 monitoring units, please contact Packet Power support for sizing assistance.

Disk drives

The storage subsystem should:

  • be implemented in RAID 10 across multiple disks

  • consist of high throughput (10,000 RPM or solid state) drives, with solid state being HEAVILY recommended.

Server platform
  • Supported environments

    • Bare metal

    • Commercial-grade virtualization platforms such as:

      • HyperV

      • KVM

      • OpenStack

      • VMWare ESX

      • VMWare vSphere

      • Xen

    • Unsupported virtualization platforms:

      • VirtualBox

      • Virtual PC

      • VMWare Player

      • VMWare Fusion

      • Open VZ

      • Parallels

  • Server OS

    • Ubuntu Linux 22.04

    • Ubuntu Linux 24.04

    • Red Hat Enterprise Linux (RHEL) 9

    • CentOS 9

    • Oracle Linux 9

  • Browsers

    • N-2 for Chrome, Firefox and MSFT (Edge and IE)

Network connectivity
  • Between servers: 100Mbit - 1Gbit

  • Gateways/HUBs to server: 10 Mbit - 1Gbit


Installation

Note: All listed commands should be run by the root user unless otherwise specified.

System Configuration

Start by setting the system timezone to UTC.

CODE
timedatectl set-timezone UTC

Third-Party Software Repositories

Node.js

CODE
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg

NODE_MAJOR=18
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list

sudo apt-get update
sudo apt-get install nodejs -y

Third-Party Software Installation

Node.js + Erlang + LAMP

Package Installation

The Ubuntu 24.04 repositories contain PHP 8.3, but 8.1 will need to be installed. All PHP packages in the installation command should be prefixed with php8.1-.

CODE
sudo add-apt-repository ppa:ondrej/php
sudo apt update
apt-get install -y php8.1 nodejs socat snmp sqlite3 apache2 libapache2-mod-php8.1 php8.1-dev php8.1-bcmath php8.1-intl php8.1-mbstring php8.1-mysql php8.1-snmp php8.1-sqlite3 php8.1-xml php8.1-zip
sudo a2dismod mpm_event && sudo a2enmod mpm_prefork && sudo a2enmod php8.1
Mosquitto
CODE
sudo apt update
sudo apt install -y mosquitto

Third-Party Software Configuration

PHP

Configure PHP timezone
CODE
echo 'date.timezone = UTC' > /etc/php/8.1/mods-available/date.ini
Install IonCube Loader
CODE
wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar -xzf ioncube_loaders_lin_x86-64.tar.gz
cp ioncube/ioncube_loader_lin_8.1.so ` php -i | grep ^extension_dir | awk '{print $3}'`
cat <<EOF > /etc/php/8.1/mods-available/ioncube.ini
; configuration for ioncube module
; priority=00
zend_extension=ioncube_loader_lin_8.1.so
EOF
Enable PHP extensions
CODE
phpenmod date
phpenmod ioncube

MySQL

Install MySQL
CODE
# Install mysql
apt-get install -y mysql-server mysql-client

# Handling EMX mysql configuration
cat <<EOT >> /etc/mysql/conf.d/emx.cnf
[mysqld]
innodb-file-per-table = on
event-scheduler = on
explicit_defaults_for_timestamp = off
sql-mode = "NO_ENGINE_SUBSTITUTION"
log_bin_trust_function_creators = 1
EOT
 
service mysql restart
Configure User Access
CODE
# Login to MySQL
mysql -uroot
  
# Create an EMX user
CREATE USER 'emx'@'localhost' IDENTIFIED BY 'S3cretP4ssword$';
GRANT ALL PRIVILEGES ON `emx`.* TO 'emx'@'localhost';
  
# Create an EMX database
CREATE DATABASE `emx`;
  
exit

Apache

Configure Apache sites
CODE
# Remove existing sites
rm -rf /etc/apache2/sites-enabled/*
rm -rf /etc/apache2/sites-available/*
   
# Clean the www directory
rm -rf /var/www
mkdir /var/www
chown www-data:www-data /var/www
   
# Setup the site
cat <<EOT > /etc/apache2/sites-available/emx.conf
<VirtualHost *:80>
 ServerName default
 DocumentRoot "/var/www"
 <Directory "/var/www">
   Options Indexes FollowSymLinks
   AllowOverride All
   DirectoryIndex index.php
 </Directory>
 ErrorLog "/var/log/apache2/emx_error.log"
 ServerSignature Off
 CustomLog "/var/log/apache2/emx_access.log" combined
</VirtualHost>
EOT
  
# Enable the rewrite module and emx site
a2enmod rewrite
a2ensite emx
Restart Apache
CODE
service apache2 restart

PM2

CODE
# Install PM2 process monitor

npm i -g pm2
 
# !! NOTE: Only run the following if disabling Keymetrics.io interaction
pm2 interact stop
pm2 interact delete

Packet Power Software Installation

EMX/OPX3

Install OPX3 Package
CODE
# Drop the OPX .deb on the server first using scp, wget, or some other means; then:
dpkg -i packetpower-opx-*.deb
  
# Edit MySQL, MQTT, and EG4-API credentials using `nano`, `vim`, or `cat` as below:
cat <<EOT > /var/pacpow-opx/config/mysql.json
{
  "host": "localhost",
  "user": "emx",
  "password": "S3cretP4ssword$",
  "database": "emx"
}
EOT

cat <<EOT > /var/pacpow-opx/config/mqtt.json
{
  "url": "mqtt://localhost:1883",
  "user": null,
  "password": null
}
EOT

cat <<EOT > /var/pacpow-opx/config/e4-api-mqtt.config.json
{
  "mqtt": {
    "url": "mqtt://localhost:1883",
    "options" : {
      "user": null,
      "password": null
    }
  },
  "emx": {
    "host":"localhost",
    "port":80
  },
  "jdrTopic":"@p2/JDR",
  "panelTopic":"@p2/PANEL"
}
EOT
Install EMX Package
CODE
# Create the support_files directory for storing firmware, etc.
mkdir -p /var/www/public/support_files/
 
# Drop the EMX .deb on the server first using scp, wget, or some other means; then:
dpkg -i packetpower-emx-*.deb
Start OPX processes
CODE
# Run OPX processes with PM2 task manager
(cd /var/pacpow-opx && pm2 start config/ecosystem.config.js)
pm2 save
pm2 startup
(Optional) Update Support Files

Note: the support files directory is hard-coded to /public/support_files, though it should be possible to symlink it to another location if necessary.  It contains node firmware files that can be sent remotely to gateways in order to broadcast updates over the mesh network.

CODE
# Copy over desired firmware files
sudo cp ~/uploaded_files/node.*.bin /var/www/public/support_files/

EMX Web Installer

Finally, complete the setup by navigating a browser to the IP address of the EMX server.  You will be greeted with a setup screen, which will prompt you for the following information:

  • MySQL credentials

  • Mosquitto configuration (used by OPX3)

    • The following is the default mosquitto configuration:

      • Hostname: 127.0.0.1 (or the IPv4 address of the appropriate server)

      • Username: blank

      • Password: blank

      • Port: 1883

  • (Optional) The SMTP server credentials to be used for alerting capabilities

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.