How to handle a main site plus multiple virtualhosts on one server

Solution 1:

Put the "main" site in a subdirectory of /var/www as well, and change your Apache configuration to reflect its new location.

Solution 2:

You do not have to mix it. Not one bit.

Place the virtual host directory in /var/vh1 /var/vh2 and so on. Its not necesary to place all of them in /var/www

An example:

Listen 80

# This is the "main" server running on 172.20.30.40
ServerName server.domain.com
DocumentRoot /www/mainserver

# This is the other address
NameVirtualHost 172.20.30.50

<VirtualHost 172.20.30.50>
DocumentRoot /www/example1
ServerName www.example.com

# Other directives here ...

</VirtualHost>

<VirtualHost 172.20.30.50>
DocumentRoot /www/example2
ServerName www.example.org

# Other directives here ...

</VirtualHost>

I took it from Apache page itself. So its pretty reliable.