Saturday, January 29, 2011

Apache: i want each user have it's own DocumentRoot e.g. ~/www

hi,

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)

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

    Webnet : Agreed, this is the setup that I use.
  • 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!

    takpar : thanks, what about ownership and permissions of `www`?
    Prix : @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.
    From jmcmurry

0 comments:

Post a Comment