0

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

1 Answer 1

3

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

2
  • what about setting permissions? should /home/web/www belong to www-data ?
    – horen
    Oct 12, 2012 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).
    – user
    Oct 12, 2012 at 8:40

You must log in to answer this question.

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