Move data & settings file to a common location?

Ok that sounds good, I am aware these changes could take a while to sort through considering all existing users, emonpi/emonbase installations etc. Im keen not to rush through changes at this point but its a good idea to discuss them so that we can get to a clearer idea of the way forward on this topic.

2 Likes

New feature branch added with proposed changes for consideration.

Paul

1 Like

I have noticed that there are 2 different locations specified for installing emoncms into, in the documentation.

One puts it into /var/www/html emoncms/LinuxInstall.md at master · emoncms/emoncms · GitHub

and the other into /var/www.emoncms/docs/RaspberryPi at master · emoncms/emoncms · GitHub and later puts in a symlink cd /var/www/html && sudo ln -s /var/www/emoncms

Which is the ‘correct’ one :smile:

Good question.

I’m trying to find a happy medium that can be used in all the guides and this is what I have so far.

For some security related reason, Apache2 decided it wasn’t a good thing to put files directly into the /var/www folder, that there must be at least one more level of folders, to that end they moved their test index.html page into a folder called html in /var/www (/var/www/html/index.html) and the 000-default vhost serves it from there.

This information was widely misunderstood to mean that the files must go in /var/www/html. The reality is they must go in a folder rather than directly into /var/www, so by just cloning emoncms into /var/www we are meeting that criteria as the emoncms folder holds all the files. However if users want serve other content but not put it in the emoncms folder, the obvious route is to make /var/www the root folder instead of /var/www/emoncms and put that content along side emoncms in /var/www thus undoing the extra folder level.

So it is IMO best to create a folder in /var/www to be the root of the new emoncms site and then clone the emoncms folder into that so that other content can be served easily by putting it in that same folder. eg /var/www/mysite/emoncms and /var/www/mysite/picturesofmycat.html. It’s safer due to the extra folder level and it complies with apache2 recommendation and it’s simpler to install/understand.

For ease I usually keep the “site folder” (aka the websites “document root”), the vhost config file, the emoncms db table and the db username all the same, the default is obviously “emoncms”. Therefore IMO /var/www/emoncms/emoncms and a matching /etc/apache2/sites-available/emoncms.conf vhost file would be the most correct for a default set up.

this then allows the site to be enabled or disabled using

sudo a2ensite emoncms

and

sudo a2dissite emoncms

and for ssl certs to be set up in that name too.

OK, I can see that. I did try initially to put it under html but could not get the rewrite rules to work properly for lighttpd.

I do think consistency is the key though unless a variation is explained.

Have you given any further thought to this - @TrystanLea

Paul

Apologies, I will try and get back to this over the coming week.

1 Like

Hello,
I’m new to emoncms and I just installed it on Debian 9.5
I’d be interested in moving the data folder to another location. What’s the status of this discussion? Did you chose the best method?
Thanks!

No decision has been made unfortunately.

Thanks for your reply Paul.

What would you advise then? For the moment, emoncms is installed under /var/www/html/emoncms/ and data is stored, as advised in the manual, in:

  • /var/lib/phpfiwa/
  • /var/lib/phpfina/
  • /var/lib/phptimeseries/

My Debian system is installed on SD card, and I’d like to move the maximum of data to the attached HDD under /media/raid/ to improve the lifetime of the hardware.

That shouldn’t be a problem. You can move the data files anywhere that you want (within reason).
You could either add symlinks to your /var/lib/phpfiwa etc folders, pointing to where you want the actual data to be stored.
Or, it would probably be more straightforward just to change the data file location in settings.php to /media/raid/ especially as no decision has been made yet in standardising paths.
You will have to stop emoncms, move your existing data folders to the new location, edit settings.php and restart emoncms for this to take effect.

Great, thank you so much!

There are a lot of paths (post process module, sync module, backup module etc) that currently look for emoncms/process_settings.php under /var/www/emoncms/process_settings.php. Should the recommendation be to also symlink /var/www/html/emoncms to /var/www/emoncms so that modules loading process_settings can always find it?

ln -s /var/www/html/emoncms/ /var/www/emoncms

There is a symlink to this effect on the emonpi

If the location of process_settings.php is known then the location of settings.php if changed to /etc/emoncms/settings.php following @Paul suggestion here https://github.com/emoncms/emoncms/compare/restructure does not need to be checked by modules such as the postprocess/sync module

Just pushed this initial PR to move from a single settings.php file to a hierarchy of ini files which is related to this discussion.