2

I want to give Apache2 write access to a directory in a users home directory so it can write logs etc.

The idea is that I add Apache2 to the users group:

sudo usermod -aG vagrant www-data

And then I simply give the directory to which I want Apache2 to be able to write "group" write and execute permissions:

chmod g+wx ./logs

However, this does not seem to work.

How do I add Apache2 to a users group and set the permissions correctly for write access?

Luke
  • 3,826
  • 8
  • 36
  • 40
  • Check permissions on parent directories to make sure they don't interfere and test/debug from command line not from apache – Ryan Babchishin Aug 15 '16 at 05:31
  • @RyanBabchishin Thanks. But check 'm for what? – Luke Aug 15 '16 at 05:42
  • 2
    Make sure apache's user can actually enter that directory. Higher level directory permissions can prevent that. That's why I said test from the command line... it will be more apparent. And if it works from the command line, and not from apache, then you know it's an apache problem. – Ryan Babchishin Aug 15 '16 at 05:46
  • May be you have enabled SELinux or apparmor. Usually I saw such problems on servers with enabled SELinux. Check it. – Alexander Tolkachev Aug 15 '16 at 21:53

1 Answers1

-2

You should enable the userdir module and then restart Apache:

$ sudo a2enmod userdir
$ sudo service apache2 restart

If it doesn't solve the problem, check Apache log: /var/log/apache2/error.log

Check this for reference: https://unix.stackexchange.com/questions/85311/apache2-userdir-enabled-but-still-have-no-access