I have the same problem with a fresh installation :
Raspberry BUSTER,
emoncms 10.1.13
I find this fix for this problem
in the file emoncms/scripts/phpmqtt.input.php , change line 46 from :
‘chdir(dirname(FILE)."/…/…/…/");’
to :
‘chdir(dirname(FILE)."/…/");’
This change fix the problem in my installation.
Ciao.
How did you do the installation?
Making that change will prevent future updates. It will be better to fix your installation than make this change.
Can you click on the button Copy as Markdown next to Server Information on the Admin page and paste here please (no further formatting required).
You seem to have installed the wrong service. It should be the emoncms_mqtt
service. the phpmqtt
is deprecated.
How did you do the install?
I do this procedure to install emoncms, mosquitto, al some other software necessary in my application in a new BUSTER lite installation. It work well
( Sorry, new users can only put 2 links in a post… i cannot include all for this reason… )
Set static IP adress
sudo nano dhcpcd.conf
#Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1
Start by updating the system repositories and packages:
sudo apt-get update && sudo apt-get upgrade
sudo nano /boot/config.txt
Add to the end of the file
dtoverlay=pi3-disable-bt
save and exit
sudo systemctl disable hciuart // disabilita BT
sudo apt-get install -y apache2 mariadb-server mysql-client php7.0 libapache2-mod-php7.0 php7.0-mysql php7.0-gd php7.0-opcache php7.0-curl php-pear php7.0-dev php7.0-mcrypt php7.0-common redis-server php-redis git build-essential php7.0-mbstring
BUSTER :
sudo apt-get install -y apache2 mariadb-server-10.3 mariadb-client-10.3 php7.0 libapache2-mod-php php-mysql php-gd php7.3-opcache php-curl php-pear php-dev php-mcrypt php-common redis-server php-redis git build-essential php-mbstring
sudo apt-get install python-serial
sudo apt-get install minicom lsof
Install the pecl dependencies (swift mailer):
sudo pear channel-discover pear.swiftmailer.org
sudo pecl channel-update pecl.php.net
sudo pecl install swift/swift redis
Issue the command:
sudo a2enmod rewrite
printf “extension=redis.so” | sudo tee /etc/php/7.0/mods-available/redis.ini 1>&2
BUSTER:
printf “extension=redis.so” | sudo tee /etc/php/7.3/mods-available/redis.ini 1>&2
printf “extension=redis.so” | sudo tee /etc/php/7.1/mods-available/redis.ini 1>&2
sudo phpenmod redis
For and <Directory /var/www/> change AllowOverride None to AllowOverride All.
This should be on, or very close to lines 161 and 172 of /etc/apache2/apache2.conf
sudo nano /etc/apache2/apache2.conf
Save & exit, then restart Apache:
sudo systemctl restart apache2
installare EMONCMS :
First, set the permissions for the www directory:
sudo chown $USER /var/www
Firstly we should secure the database server, and then create a database and database user for emoncms to use;
The following configuration commands gives ‘sudoers’ Mariadb root privileges from within the local network, to administer all aspects of the databases and users. It also removes an ‘example’ database and user, which is no longer required.
sudo mysql -e “DELETE FROM mysql.user WHERE User=‘root’ AND Host NOT IN (‘localhost’, ‘127.0.0.1’, ‘::1’); DELETE FROM mysql.user WHERE User=’’; DROP DATABASE IF EXISTS test; DELETE FROM mysql.db WHERE Db=‘test’ OR Db=‘test_%’; FLUSH PRIVILEGES;”
sudo mysql -e “CREATE DATABASE emoncms DEFAULT CHARACTER SET utf8;”
Add an emoncms database user and set that user’s permissions.
sudo mysql -e “CREATE USER ‘emoncms’@‘localhost’ IDENTIFIED BY ‘PWD’; GRANT ALL ON emoncms.* TO ‘emoncms’@‘localhost’; flush privileges;”
Create data repositories for emoncms feed engines:
sudo mkdir /var/lib/{phpfiwa,phpfina,phptimeseries}
…and set their permissions
sudo chown www-data:root /var/lib/{phpfiwa,phpfina,phptimeseries}
Set write permissions for the emoncms logfile:
sudo touch /var/log/emoncms.log && sudo chmod 666 /var/log/emoncms.log
cd /var/www/html && sudo ln -s /var/www/emoncms
Disable serial console boot
sudo nano /boot/cmdline.txt
by changing the line to -
dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=66831de6-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
sudo systemctl stop [email protected]
sudo systemctl disable [email protected]
Installare MQTT
sudo apt-key add mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo wget mosquitto-stretch.list
sudo apt-get update
apt-cache search mosquitto
sudo apt-get install mosquitto mosquitto-clients -y
sudo apt-get install libmosquitto-dev
sudo pecl install Mosquitto-alpha
sudo phpenmod mosquitto
sudo cp /var/www/emoncms/scripts/mqtt_input.service /etc/systemd/system/mqtt_input.service
sudo systemctl daemon-reload
sudo systemctl enable mqtt_input.service
sudo systemctl start mqtt_input
installazione di PHPMYADMIN
sudo mysql
CREATE USER ‘user’@‘localhost’ IDENTIFIED BY ‘**********’;
GRANT ALL ON . TO ‘user’@‘localhost’;
FLUSH PRIVILEGES;
exit
sudo mv phpMyAdmin-4.8.4-all-languages phpmyadmin
sudo mv phpMyAdmin-4.9.2-all-languages phpmyadmin
sudo rm phpMyAdmin-4.8.4-all-languages.tar.gz
sudo rm phpMyAdmin-4.9.2-all-languages.tar.gz
cd /var/www/html && sudo ln -s /var/www/phpmyadmin
INSTALLARE MINICOM
sudo apt-get install minicom
TEST :
minicom -b 9600 -o -D /dev/ttyAMA0
Disable HDMI
If you’re using the Pi without a monitor, you can simple turn off HDMI output like so:
/usr/bin/tvservice -o
(use /usr/bin/tvservice -p to turn back on). Add the line to /etc/rc.local to make it permanent, otherwise it will only work until the next reboot.
Varie:
sudo usermod -a -G dialout www-data
Server Information
Server Information
Services
- mqtt_input :- Active Running
- redis-server :- Active Running
- mosquitto :- Active Running
Emoncms
- Version :- 10.1.13
- Modules :- Administration | App v2.0.9 | Dashboard v2.0.5 | EventProcesses | Feed | Graph v2.0.6 | Input | CoreProcess | Schedule | Time | User | Visualisation
-
Git :-
- URL :- GitHub - emoncms/emoncms: Web-app for processing, logging and visualising energy, temperature and other environmental data
- Branch :- * stable
- Describe :- 10.1.11-7-g90f39158
Server
- OS :- Linux 4.19.75-v7+
- Host :- raspberrypi | raspberrypi | (192.168.1.241)
- Date :- 2019-12-08 19:26:09 CET
- Uptime :- 19:26:09 up 0 min, 0 users, load average: 0.96, 0.29, 0.10
Memory
-
RAM :- Used: 14.00%
- Total :- 937.97 MB
- Used :- 131.31 MB
- Free :- 806.66 MB
-
Swap :- Used: 0.00%
- Total :- 100 MB
- Used :- 0 B
-
Free :- 100 MB
Write Load Period
Disk
-
/ :- Used: 30.92%
- Total :- 6.82 GB
- Used :- 2.11 GB
- Free :- 4.4 GB
- Write Load :- -317.46 B/s (1 days 17 mins)
-
/boot :- Used: 20.55%
- Total :- 252.05 MB
- Used :- 51.79 MB
- Free :- 200.25 MB
- Write Load :- -0.05 B/s (1 days 17 mins)
HTTP
- Server :- Apache/2.4.38 (Raspbian) HTTP/1.1 CGI/1.1 80
MySQL
- Version :- 5.5.5-10.3.17-MariaDB-0+deb10u1
- Host :- localhost:6379 (127.0.0.1)
- Date :- 2019-12-08 19:26:09 (UTC 01:00)
- Stats :- Uptime: 21833 Threads: 11 Questions: 276 Slow queries: 0 Opens: 63 Flush tables: 1 Open tables: 57 Queries per second avg: 0.012
Redis
-
Version :-
- Redis Server :- 5.0.3
- PHP Redis :- 5.1.1
- Host :- localhost:6379
- Size :- 233 keys (768.31K)
- Uptime :- 0 days
MQTT Server
- Version :- Mosquitto 1.6.8
- Host :- localhost:1883 (127.0.0.1)
PHP
- Version :- 7.3.11-1~deb10u1 (Zend Version 3.3.11)
- Modules :- apache2handler | calendar v7.3.11-1~deb10u1 | Core v7.3.11-1~deb10u1 | ctype v7.3.11-1~deb10u1 | curl v7.3.11-1~deb10u1 | date v7.3.11-1~deb10u1 | dom v20031129 | exif v7.3.11-1~deb10u1 | fileinfo v7.3.11-1~deb10u1 | filter v7.3.11-1~deb10u1 | ftp v7.3.11-1~deb10u1 | gd v7.3.11-1~deb10u1 | gettext v7.3.11-1~deb10u1 | hash v7.3.11-1~deb10u1 | iconv v7.3.11-1~deb10u1 | igbinary v3.0.0 | json v1.7.0 | libxml v7.3.11-1~deb10u1 | mbstring v7.3.11-1~deb10u1 | mosquitto v0.4.0 | mysqli v7.3.11-1~deb10u1 | mysqlnd vmysqlnd 5.0.12-dev - 20150407 - $Id: 7cc7cc96e675f6d72e5cf0f267f48e167c2abb23 $ | openssl v7.3.11-1~deb10u1 | pcre v7.3.11-1~deb10u1 | PDO v7.3.11-1~deb10u1 | pdo_mysql v7.3.11-1~deb10u1 | Phar v7.3.11-1~deb10u1 | posix v7.3.11-1~deb10u1 | readline v7.3.11-1~deb10u1 | redis v5.1.1 | Reflection v7.3.11-1~deb10u1 | remctl v3.15 | session v7.3.11-1~deb10u1 | shmop v7.3.11-1~deb10u1 | SimpleXML v7.3.11-1~deb10u1 | sockets v7.3.11-1~deb10u1 | sodium v7.3.11-1~deb10u1 | SPL v7.3.11-1~deb10u1 | standard v7.3.11-1~deb10u1 | sysvmsg v7.3.11-1~deb10u1 | sysvsem v7.3.11-1~deb10u1 | sysvshm v7.3.11-1~deb10u1 | tokenizer v7.3.11-1~deb10u1 | wddx v7.3.11-1~deb10u1 | xml v7.3.11-1~deb10u1 | xmlreader v7.3.11-1~deb10u1 | xmlwriter v7.3.11-1~deb10u1 | xsl v7.3.11-1~deb10u1 | Zend OPcache v7.3.11-1~deb10u1 | zlib v7.3.11-1~deb10u1
Pi
-
Model :- Raspberry Pi 3 Model B+ Rev 1.3 - 1GB (Sony UK)
-
Serial num. :- 5F94FD3C
-
Temperature :- 28.94°C - N/A (to show GPU temp execute this command from the console “sudo usermod -G video www-data” )
-
emonpiRelease :- - File-system :- read-write
you can indicate the correct procedure to install emoncms_mqtt service ?
thanks…
I have increased your level so could you post a link to where you found those instructions. They are old and should not be used.
Do you have anything else installed on this RPi? If not then you will be better to start again with the EmonSD image. It is likely there are other issues with your installation which makes helping you very difficult.
This is my note for install emoncms in STRETCH and BUSTER :
Set static IP adress
sudo nano dhcpcd.conf
#Example static IP configuration:
interface eth0
static ip_address=192.168.1.241
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8 fd51:42f8:caae:d92e::1
Start by updating the system repositories and packages:
sudo apt-get update && sudo apt-get upgrade
sudo nano /boot/config.txt
Add to the end of the file
dtoverlay=pi3-disable-bt
save and exit
sudo systemctl disable hciuart // disabilita BT
STRETCH :
sudo apt-get install -y apache2 mariadb-server mysql-client php7.0 libapache2-mod-php7.0 php7.0-mysql php7.0-gd php7.0-opcache php7.0-curl php-pear php7.0-dev php7.0-mcrypt php7.0-common redis-server php-redis git build-essential php7.0-mbstring
BUSTER :
sudo apt-get install -y apache2 mariadb-server-10.3 mariadb-client-10.3 php7.0 libapache2-mod-php php-mysql php-gd php7.3-opcache php-curl php-pear php-dev php-mcrypt php-common redis-server php-redis git build-essential php-mbstring
sudo apt-get install python-serial
sudo apt-get install minicom lsof
Install the pecl dependencies (swift mailer):
sudo pear channel-discover pear.swiftmailer.org
sudo pecl channel-update pecl.php.net
sudo pecl install swift/swift redis
Issue the command:
sudo a2enmod rewrite
STRETCH :
printf “extension=redis.so” | sudo tee /etc/php/7.0/mods-available/redis.ini 1>&2
BUSTER:
printf “extension=redis.so” | sudo tee /etc/php/7.3/mods-available/redis.ini 1>&2
printf “extension=redis.so” | sudo tee /etc/php/7.1/mods-available/redis.ini 1>&2sudo phpenmod redis
For <Directory />
and <Directory /var/www/>
change AllowOverride None to AllowOverride All.
This should be on, or very close to lines 161 and 172 of /etc/apache2/apache2.conf
sudo nano /etc/apache2/apache2.conf
Save & exit, then restart Apache:
sudo systemctl restart apache2
installare EMONCMS :
First, set the permissions for the www directory:
sudo chown $USER /var/www
cd /var/www && git clone -b stable GitHub - emoncms/emoncms: Web-app for processing, logging and visualising energy, temperature and other environmental data
Firstly we should secure the database server, and then create a database and database user for emoncms to use;
The following configuration commands gives ‘sudoers’ Mariadb root privileges from within the local network, to administer all aspects of the databases and users. It also removes an ‘example’ database and user, which is no longer required.
sudo mysql -e “DELETE FROM mysql.user WHERE User=‘root’ AND Host NOT IN (‘localhost’, ‘127.0.0.1’, ‘::1’); DELETE FROM mysql.user WHERE User=‘’; DROP DATABASE IF EXISTS test; DELETE FROM mysql.db WHERE Db=‘test’ OR Db=‘test_%’; FLUSH PRIVILEGES;”
sudo mysql -e “CREATE DATABASE emoncms DEFAULT CHARACTER SET utf8;”
Add an emoncms database user and set that user’s permissions.
sudo mysql -e “CREATE USER ‘emoncms’@‘localhost’ IDENTIFIED BY ‘PWD’; GRANT ALL ON emoncms.* TO ‘emoncms’@‘localhost’; flush privileges;”
Create data repositories for emoncms feed engines:
sudo mkdir /var/lib/{phpfiwa,phpfina,phptimeseries}
…and set their permissions
sudo chown www-data:root /var/lib/{phpfiwa,phpfina,phptimeseries}
Set write permissions for the emoncms logfile:
sudo touch /var/log/emoncms.log && sudo chmod 666 /var/log/emoncms.log
cd /var/www/html && sudo ln -s /var/www/emoncms
Disable serial console boot
sudo nano /boot/cmdline.txt
by changing the line to -
dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=66831de6-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
sudo systemctl stop [email protected]
sudo systemctl disable [email protected]
Installare MQTT
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
STRETCH :
sudo wget http://repo.mosquitto.org/debian/mosquitto-stretch.list
X BUSTER:
sudo wget http://repo.mosquitto.org/debian/mosquitto-buster.list
sudo apt-get update
apt-cache search mosquitto
sudo apt-get install mosquitto mosquitto-clients -y
sudo apt-get install libmosquitto-dev
sudo pecl install Mosquitto-alpha
STRETCH :
printf “extension=mosquitto.so” | sudo tee /etc/php/7.0/mods-available/mosquitto.ini 1>&2
BUSTER:
printf “extension=mosquitto.so” | sudo tee /etc/php/7.1/mods-available/mosquitto.ini 1>&2
printf “extension=mosquitto.so” | sudo tee /etc/php/7.3/mods-available/mosquitto.ini 1>&2
sudo phpenmod mosquitto
sudo cp /var/www/emoncms/scripts/mqtt_input.service /etc/systemd/system/mqtt_input.service
sudo systemctl daemon-reload
sudo systemctl enable mqtt_input.service
sudo systemctl start mqtt_input
installazione di PHPMYADMIN
sudo mysql
CREATE USER ‘portalsole’@‘localhost’ IDENTIFIED BY ‘**********’;
GRANT ALL ON . TO ‘portalsole’@‘localhost’;
FLUSH PRIVILEGES;
exit
cd /var/www
sudo wget https://files.phpmyadmin.net/phpMyAdmin/4.9.2/phpMyAdmin-4.9.2-all-languages.tar.gz
sudo tar -xvf phpMyAdmin-4.9.2-all-languages.tar.gz
sudo mv phpMyAdmin-4.9.2-all-languages phpmyadmin
sudo rm phpMyAdmin-4.9.2-all-languages.tar.gz
cd /var/www/html && sudo ln -s /var/www/phpmyadmin
INSTALLARE MINICOM
sudo apt-get install minicom
TEST :
minicom -b 9600 -o -D /dev/ttyAMA0
Disable HDMI
If you’re using the Pi without a monitor, you can simple turn off HDMI output like so:
/usr/bin/tvservice -o
(use /usr/bin/tvservice -p to turn back on). Add the line to /etc/rc.local to make it permanent, otherwise it will only work until the next reboot.
Varie x permettere a php di usare la seriale:
sudo usermod -a -G dialout www-data
This is not a recommended method of installation. You have not installed additional modules, some of the services are incorrect, you have not installed Mosquitto from the apt repo (and that is just what I have found after a quick scan).
I’m sorry, but this is not supportable. If you have issues, you will need to fix them yourself.
Cheers
Brian
I’m seeing this too on my installation. I’m on an emonpi running emonSD-03May16
. To be fair, I believe this isn’t supported now with the latest emoncms, but I keep this up-to-date myself.
What I’m really confused by is that we have this file:
And in there we have:
chdir(dirname(__FILE__)."/../../../");
require "Lib/EmonLogger.php";
So essentially we can boil the require down to trying to pull in:
dirname(__FILE__)/../../../Lib/EmonLogger.php
But that’s not where that file is in the repo. It is actually in:
dirname(__FILE__)/../Lib/EmonLogger.php
Just looking at the repo on github we can see that.
So how does this work for anyone?
I see that the chdir
was changed in this commit:
But I cannot see from that why it would be. scripts/phpmqtt_input.php
stays in exactly the same place. So why would we change how to get to the root of the emoncms installation? We’re going 2 levels up from the emoncms installation with that chdir
now?
What repositories do you use? ‘up-to-date’ - i.e. you are now on Buster?
That script has been deprecated - emoncms_mqtt
is now the maintained script.
pi@emonpi:~ $ systemctl status emoncms_mqtt.service
● emoncms_mqtt.service - Emoncms emoncms_mqtt script
Loaded: loaded (/var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-06-05 20:07:05 BST; 3 weeks 5 days ago
Docs: https://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/MQTT.md
Main PID: 29471 (php)
Tasks: 1 (limit: 2319)
Memory: 9.9M
CGroup: /system.slice/emoncms_mqtt.service
└─29471 /usr/bin/php /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.php
Ah i see! Well that is indeed why the chdir
was changed for scripts/services/emoncms_mqtt/emoncms_mqtt.php
. That needs the extra 2 ../../
. But the old one is therefore broken.
I am on the stock from emonSD-03May16 which is jessie. So very old for sure.
It makes sense on the new service though - that explains why new installations don’t have the problem. But should we fix the old one if the script is still there so that people still using that can? Or alternatively, remove the file to indicate it really is no longer supported?
Or alternatively move to a supported OS. Jessie is way EOL.