Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When setting up a vhost and choosing a DocumentRoot can I set it to a folder outside /var/www e.g. var/www2 or do I have to stay inside e.g. /var/www/site2 ?

System: Ubuntu / Apache2

share|improve this question

You can set it to whatever directory you want, for example:

DocumentRoot /home/web/www

and dont forget to add directory settings like:

<Directory "/home/web/www/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all


If you are running single site I would suggest you to add that user/group (in this case user web)

User web

Group web



if you are running multiple sites create a new group and add those users to that group, in /etc/apache.conf add

Group your-new-group

I hope this helps

share|improve this answer
what about setting permissions? should /home/web/www belong to www-data ? – horen Oct 12 '12 at 8:17
It doesn't need to, but it must be accessible by the user that the web server runs as. This means minimum execute permission on all directories in the hierarchy, as well as read permission if you want directory indexes. 0755 or 0775, with ownership as responsible-user:responsible-group is probably a common setup, but you could easily tighten that down to 0710 with ownership responsible-user:web-server-group if you want to (assuming the web server doesn't need write access). – Michael Kjörling Oct 12 '12 at 8:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.