I have a webserver that uses apache. When I do a ls -l
on /var/www/project1/public_html
and /var/www/project2/public_html
, I see that they are owned by projectuser1
and projectuser2
respectively.
On some of other servers I've looked at, both /var/www/project1/public_html
and /var/www/project2/public_html
are owned by only www-data. How would I go about changing these ownerships to projectuser1
and projectuser2
such that these new users can login to their areas and manage their own websites?
I created a user projectuser1
then did a chown -R projectuser1 /var/www/project1
, but any time projectuser1
adds a new file to the directory, Apache gives me a Permission Error. If do a chown -R www-data /var/www/project1
, then everything works again.
Ultimately, I want apache to serve the /var/www/project1
directory with projectuser1
owning it.
Best Answer
There a two simple answers for your question:
You could add the www-data group to each projectuser with
usermod -aG www-data projectuser%
and then ensure that group permissions are at least g+rw withchown -R g+rw /path/to/dir
.There is a module that runs each child process as a different user called mpm-itk. This allows you to run each vhost under a separate userid.