Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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
</Directory>

----Edited----

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

User web

Group web

to

/etc/apache.conf

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
1  
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

 
discard

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.