0

i want to configure Apache2 so that each user have his/her own DocumentRoot and instead of /var/www put the files in /home/john/www (john is a username smple)

2 Answers 2

2

The Apache manual has that covered. Basically, you need to enable a module in your server configuration, set the local path and you're done. In your case, the local path should be something like:

UserDir /home

This automatically expands to /home/username.

In my opinion, though, going with a public_html folder (or similar) is better. This allows your users to store data that is not accessible via web.

1
  • Agreed, this is the setup that I use.
    – Ben
    Aug 29, 2010 at 22:01
2

You want Apache's mod_userdir module:

http://httpd.apache.org/docs/2.2/mod/mod_userdir.html

Specifically, search your existing configuration files for "UserDir" (might be in the main httpd.conf, in extra/httpd-userdir.conf, or in some other file depending on where you got Apache.) Uncomment it and set it to this:

UserDir www

Remember to enable the mod_userdir module (or uncomment "Include conf/extra/httpd-userdir.conf" in httpd.conf, whichever applies) to allow the module to be loaded!

2
  • thanks, what about ownership and permissions of www?
    – Alexar
    Aug 29, 2010 at 21:51
  • @takpar it would work under apache user and group so you would need to either give the right chmods or to create a virtualhost for each domain using suExec and suPHP so both, php and py,perl etc would work under that given user.
    – Prix
    Aug 29, 2010 at 22:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .