0

I have changed my DocumentRoot to ~/www. The permissions of it are 0774. I have added the www-data user to my user's group and the owner of ~/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. The opposite thing applies too.

This is more like a Linux question, not Ubuntu but I really hope that you can help me. Thanks!

Stanislav
  • 225
  • 1
  • 9
  • 2
    DocumentRoot must be an absolute path, you can't use ~/www in order to instruct Apache to get data from /home/YOURUSERNAME/www. It will be useful if you tell us what exactly have you done in order to change the DocumentRoot. No special permissions/group is needed for this task as mentioned in previous similar answers like this http://askubuntu.com/questions/259013/how-to-move-www-directory-to-home so please edit your question in order to include as many details as you can in order to have a better scenario of your situation thus provide you the proper support. Thank you! – Geppettvs D'Constanzo Oct 04 '13 at 23:33
  • I assume he is referring to the `httpd-userdir.conf` where you can find `UserDir www` `` ` #AllowOverride FileInfo AuthConfig Limit Indexes` ` #Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec` `#Require method GET POST OPTIONS` `` – Stanislav Apr 28 '15 at 04:14

1 Answers1

3

There are two ways to solve this. One is definitely preferred over the other.

The preferred method:

Chown the DocumentRoot directory so that www-data is the owner chown -R www-data:www-data ~/www. Then set the permissions so that anyone in the www-data group can read and write to the directory 775 is a good choice.

Then add yourself to the www-data group sudo adduser <username> www-data

Log out and back in for changes to take effect, now you and apache can write to the directory

You could also solve this problem changing the apache user and group to your user and group, but that's just a bad idea.

Dan
  • 6,715
  • 5
  • 26
  • 43