EmonCMS Installation Scripts on Ubuntu 18.04

Instead of creating a new thread each time I’ve got a question I’ll … create a new thread with a more generic name and ask new questions here.

My latest question is related to config.ini which contains this:

# EmonHub: comment out line above "emoncms_modules[config]=stable" if
# you do not wish to have the emoncms emonhub config module installed

I can’t find “emoncms_modules[config]=stable” anywhere in the config.ini. Are those two lines just leftovers from a previous incarnation where it did exist? Or am I misunderstanding something here?

Yes it has changed slightly, see this line:
EmonScripts/emonsd.config.ini at master · openenergymonitor/EmonScripts · GitHub

In the redis.sh script, I think this portion is responsible for installing redis.so and configuring PHP to be able to use it.

if [ "$install_php" = true ]; then 
    echo "-------------------------------------------------------------"
    printf "\n" | sudo pecl install redis
    echo "-------------------------------------------------------------"

    PHP_VER=$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d"." )
    # Add redis to php mods available 
    printf "extension=redis.so" | sudo tee /etc/php/$PHP_VER/mods-available/redis.ini 1>&2
    sudo phpenmod redis
fi

Why not just a single line of “apt-get install php-redis”? I think the latest raspbian will install v5.0.2. However, on Ubuntu v5.1.1 is installed, the same version as is installed by the script snippet above. Are the differences between 5.0.2 and 5.1.1 big enough to make it necessary to install using pecl instead of apt?
Both will obviously achieve the same end-result. However, using apt would simplify the script slightly.

There are 3 ‘Redis’ packages;

  1. Redis server (from apt)
  2. PHP redis add on (from PECL)
  3. Python Redis package from PIP.

To clarify, what I was asking was if “apt-get install php-redis” could replace the script snippet shown? I didn’t mean to suggest that it could replace all redis installation. So “apt-get install -y redis-server”, which is in the redis.sh script would still be needed as would “sudo pip install redis”.

This is currently the complete script:

#!/bin/bash
source load_config.sh

echo "-------------------------------------------------------------"
echo "Redis configuration"
echo "-------------------------------------------------------------"
sudo apt-get install -y redis-server

if [ "$install_php" = true ]; then 
    echo "-------------------------------------------------------------"
    printf "\n" | sudo pecl install redis
    echo "-------------------------------------------------------------"

    PHP_VER=$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d"." )
    # Add redis to php mods available 
    printf "extension=redis.so" | sudo tee /etc/php/$PHP_VER/mods-available/redis.ini 1>&2
    sudo phpenmod redis
fi

sudo pip install redis

# Disable redis persistance
sudo sed -i "s/^save 900 1/#save 900 1/" /etc/redis/redis.conf
sudo sed -i "s/^save 300 1/#save 300 1/" /etc/redis/redis.conf
sudo sed -i "s/^save 60 1/#save 60 1/" /etc/redis/redis.conf
sudo systemctl restart redis-server

I’m suggesting (if possible?) to replace the content of the script with this:

#!/bin/bash
source load_config.sh

echo "-------------------------------------------------------------"
echo "Redis configuration"
echo "-------------------------------------------------------------"
sudo apt-get install -y redis-server

if [ "$install_php" = true ]; then 
   sudo apt-get install -y php-redis
fi

sudo pip install redis

# Disable redis persistance
sudo sed -i "s/^save 900 1/#save 900 1/" /etc/redis/redis.conf
sudo sed -i "s/^save 300 1/#save 300 1/" /etc/redis/redis.conf
sudo sed -i "s/^save 60 1/#save 60 1/" /etc/redis/redis.conf
sudo systemctl restart redis-server

On Ubuntu 18.04 this should work as is. Unless there are important differences between v5.0.2 and 5.1.1 of redis.so it should also work on a Raspbian system.

OK, sorry misunderstood.

sudo pecl install redis

v

sudo apt-get install -y php-redis

Historically this was because the apt repositories were behind the PECL releases (as Raspbian still is).

The advantage of using PECL is that all (Debian?) based installs will be using the same version thus removing a difference that may cause an issue (as it did in the past). I can’t see the current method causes enough of a complication in the install script to be worth changing it, and keeps everyone using the same version of php-redis.

I can see the value of the argument that it keeps everyone on the same version. However, a counter-argument for that could be that there are several other packages that are installed using apt-get and therefore there will be other packages that will not necessarily be the same version between different Debian based installs.

There is also value in not changing something that works.

If the days of an old repository version causing an issue are over, the argument for making a change is still that:

  • It simplifies the scripts
  • There is value in using the distro packages (if they exist and are new enough) instead of installing the same software from elsewhere (even if it is official enough).
  • For those (like me), installing Emoncms on a server which is also running other software in addition to Emoncms, it may make interoperability simpler (php-redis was was already installed with the other software I’m using, php-redis ).

This is not something I feel strongly about, insisting the script must be changed, I’m just raising pros and cons (and I think there are more pros than cons from using the distro packages where possible).