Multi-Virtualhost Apache2 Raspberry Pi

I’ve installed a new copy of Emoncms using the script at

This was on a fresh install of Raspbian Buster. I used emonSD_pi_env=0 in my emonsd.config.ini for the install as I just want Emoncms, not Emonhub as well.

It went smoothly, except the script seemed to have forgotten to install the python3-redis module needed for the service-runner. (that service-runner.py wouldn’t run).

After fixing that, I had a good install of Emoncms.

However - I have a question. With this setup, I can’t seem to figure out how to get Emoncms to play nice with other Apache2 Virtualhosts on the same Pi.

For instance, I want /emoncms to be just that, Emoncms. I want my root or / directory to be something else, (like wordpress or similar) I had this previously set up on an old non-scripted install of Emoncms.

I set up my virtual hosts how I want them, and got rid of the index.html that the Emoncms script puts in the /var/www/html/ directory to forward over to Emoncms. This then just 404s when attempting to navigate to /emoncms.

Anyone done anything similar using the Emoncms Install scripts?

In attempt to be more clear -

The default EmonScripts/emoncms.conf at master · openenergymonitor/EmonScripts · GitHub
has the Document root to be /var/www/emoncms.

Essentially, I want the DocumentRoot to be /var/www/html.

I’ve been able to get it to work using DocumentRoot of /var/www/ but I’m not sure that’s proper. I want to use the symlinks in /var/www/html properly.

To fix this, I’d start from scratch again.

If on a Pi you need that to be 1 does things re the pi user.

If you don’t want emonhub then edit the config file before install to remove it. You need to edit the config.ini file (not the default)

Change this line to false

The document route should indeed not be /var/www/ but /var/www/html is just an example folder for the default “hello this is Apache” page to reside in. Any website should indeed be in a folder within /var/www/ eg like /var/www/emoncms, whilst you can use /var/www/html you’d be better off using something like /var/www/myawesomesitesrootfolder and creating a new virtualhost pointing at that folder. In that folder you can have a symlink to /var/www/emoncms to give you the /emoncms sub-directory. This avoids confusion with or changing of the default /var/www/html/ folder and/or the existing emoncms virtual host that should/could be disabled if you are accessing emoncms via another virtual host.

Thanks for the help everyone! I’m going to wipe and reinstall using Brian’s advice.

Then I’ll attempt to take Paul’s advice and symlink to emoncms in ‘myawesomesitesrootfolder’.

I’ll report back!

Thanks again for the help! It looks like that emonSD_pi_env=1 helped loads. Now everything works how I think it should. No issues with installation, and I omitted everything that is normally installed on an EmonPi setup as I don’t require those modules/wifi control etc in my setup.

Got my Pi set up with my many web based tools again like HomeAssistant, Nodered, Wordpress, and others.

Be aware these (especially Home Assistant), put a high write load on the SD Card which can cause relatively early failure.

Yep, I am. I’m booting off an SSD using a USB3 to SATA adapter. No SD card to be found on this Pi 4!

2 Likes