I have changed my DocumentRoot to /home/user/www
. To achieve that I have just changed the 2 occurrences of the path at /etc/apache2/sites-available/default.
The permissions of /home/user/www are 0774. I have added the www-data user to my user's group and the owner of /home/user/www
is my own user and group (user:user).
I have done that by:
sudo chmod -R 0774 www
sudo chown -R user:user www
sudo adduser www-data user
The problem is that Apache can't write to this directory. It can write only if I set www-data as owner, but if I do that, I can't write at the directory.
I have tested the permissions with:
sudo -u www-data ls /home/user/www
sudo -u www-data cat /home/user/www/some-file
and it works.
But the WordPress I have at www
can't delete or create files. Any ideas?
Best Answer
You would have been better off with the www directory at /var/www, with owner www-data and group www-data, and adding your user to the www-data group.
First, change the DocumentRoot etc back to /var/www in the apache config.
The /var/www directory (and all subdirectories in it) should be setgid, so that files and dirs are created with group www-data.
All of the following should be run as root, or with sudo:
if there were any files in /home/user/www that you want to keep, move them to /var/www now with:
Now fix the permissions and ownership of the /var/www directory.
The next time 'user' logins in (or runs
newgrp www-data
), they should have write permission in /var/wwwBTW, if you want to make it easy for 'user' to find the web files, just make a symlink in their home directory: