-
Notifications
You must be signed in to change notification settings - Fork 298
web permission troubleshooting
WeeWX itself does not come with a webserver, so the user is responsible for installing the webserver of their choice 'and' properly integrating the two together so they work together seamlessly. Greater than zero work is generally required, but there are so many possible webserver configurations that it can be difficult to find how to do so.
This document discusses common permission-related issues users may run into.
The most frequent issue seen is permission denied when the web pages and images are generated. Example log entries generally look somewhat like the following:
ERROR weewx.imagegenerator: Unable to save to file
'/var/www/html/weather/daybarometer.png' [Errno 13]
Permission denied: '/var/www/html/weather/daybarometer.png'
WeeWX versions prior to v5 ran as user 'root', effectively being able to write anywhere in the filesystem. WeeWX v5, however, runs as an unprivileged user ('weewx' for packaged installations, or the user that ran 'pip' for pip installations). This means that the user may need to manually set permissions on their desired WeeWX output directory.
By default, a webserver will run as its own user (e.g., 'www-data') and its html document tree will not permit world write by other unprivileged users (such as 'weewx' or 'pi'). While the default v5 setting would try to write to /var/www/html/weewx
, this directory does not exist and the weewxd process has no permissions to create it nor write into it.
The easiest fix is to make certain the HTML output directory set in weewx.conf exists and is writable by the user running weewxd
.
To do this, create the /var/www/html/www
directory manually and set its owner:group to the user:group weewxd runs as. This would be 'weewx:weewx' for packaged installations, or the user:group of the user pip was run as for pip installations (for a raspberry pi, this is typically pi:pi).
So for packaged installations, with weewxd running as the user 'weewx':
sudo mkdir -p /var/www/html/weewx
sudo chown weewx:weewx /var/www/html/weewx
Or for pip installations, assuming that weewxd runs as the user 'pi':
sudo mkdir -p /var/www/html/weewx
sudo chown pi:pi /var/www/html/weewx
If this is a packaged installation, you are running as 'weewx'.
If this is a pip installation, you can look it up via the 'ps' command below.
pi@pi4:~$ ps axu | grep weewxd | grep -v grep
pi 1207 0.1 0.7 83656 30348 ? Ssl May26 13:04 /home/pi/weewx-venv/bin/python3 /home/pi/weewx-venv/lib/python3.9/site-packages/weewxd.py --log-label weewxd-ecowitt /home/pi/weewx-data/ecowitt.conf
So in this example, I am running a pip installation (see the venv?) as user pi (first column in the output).
There are a large variety of ways to configure WeeWX and a webserver to work together. See the Users Guide link for more information and pointers.