I'm running a local apache2 web server at /var/www/.
In order to use the fopen() function in php, the user and group of my site directory must both be 'www-data'. Problem is, when I try to edit files as normal user in the website directory, the normal user has insufficient permissions to write.
1 Answer
To enable both your ordinary user and the php interpreter to read and write the same files - and assuming the www-data group already has read + write permissions on the files - you can add your user to the www-data group.
sudo gpasswd -a david www-dataThis won't take effect until you logout and log back in again. Until then, you will be able "spoof" being in the www-data group with:
newgrp www-dataThis will cause your shell to fork into a newgrp process, during which you'll have a new shell session with belonging to www-data group.
You can exit this with Ctrl+D