I am running into an issue with my Apache install whereby my PHP applications cannot create their log files due to permission denied when attempting to write into the web root.
This is happening on my test server, which is a LAMP stack on Ubuntu 16.04 inside Virtual Box. The installation is pretty much as standard as comes down from apt (user is www-data, /var/www is the web root, as onwned by root).
Each project I wish to run is in it's own Virtual Host, created as follow:
- sudo mkdir -p /var/www/site1.com
- sudo chown -R $USER:$USER /var/www/site1.com
- sudo chmod -R 755 /var/www
When I wish to test, I scp (as the Ubuntu OS user) the code to the /var/www/site directory (actually, I have a sync script which does this whenever it detects code changes).
This is working fine, except for the fact that the app's can't create their log files.
I have seen several answers, including to chmod 777 everything (?!), to add the Ubuntu user to the www-data group, and to add the www-data user to the ubuntu user's group.
My preference is to add the www-data user to the Ubuntu user's group and give g+w privileges to anything that needs to be written;
Is this the correct procedure?