1

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).

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.

0

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).

This way, you have give yourself the rights to edit Apache files.

What you need to do is the opposite: give Apache the rights to edit your files:

sudo adduser www-data $USER

This way you can have /home/user/www owned by $USER:$USER: you will be able to edit files, Apache will be able to edit them.

This may not be enough, however. You said:

The permissions of /home/user/www are 0774.

Nice, but: you first have to be sure that the mode bits of /, /home and /home/user are correct. And that's still not enough: even if Apache can access /home/user/www, you need to be sure that it can access the directory contents too.

If you want to make experiments and see what's wrong, try:

sudo -u www-data ls /home/user/www
sudo -u www-data cat /home/user/www/some-file
sudo -u www-data touch /home/user/www/some-file
  • And who should be the owner of www after that? www-data:www-data ? – barakuda28 Oct 5 '13 at 12:14
  • @user199003: I've updated my answer. – Andrea Corbellini Oct 5 '13 at 12:18
  • sudo adduser www-data $USER is exactly what I did before, probably I didn't explain it properly. I have tried sudo -u www-data ls /home/user/www and sudo -u www-data cat /home/user/www/some-file and they both work. What do you mean by the mode bits of /, /home and /home/user are correct? Mode bits? What is that? – barakuda28 Oct 5 '13 at 13:16
  • I have a Wordpress in www and it can't install a plugin, it asks for FTP - this is the actual problem. – barakuda28 Oct 5 '13 at 13:17
  • Even if I set permissions of 0777, it still won't work. It works for apache only if www-data is the owner. – barakuda28 Oct 5 '13 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.