LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   debian with apache2 configuration for many VirtualHosts (https://www.linuxquestions.org/questions/linux-server-73/debian-with-apache2-configuration-for-many-virtualhosts-585719/)

scottley 09-19-2007 01:05 AM

debian with apache2 configuration for many VirtualHosts
 
Hello all. I just got finished bangin my head against Apache documentation, forum posts, and my monitor and here is what I've come up with (and confirmed as working)
Debian by default uses a2ensite/a2dissite to link Virtual Host files (you create) in the /etc/apache2/sites-available to /etc/apache2/sites-enabled. This is fine if you have one site or even two (and are really careful). But if you, like me, host many sites off the same IP address, then you will find the following information very helpful. By the way, if I am wrong, PLEASE tell me.
at the end of /etc/apache2/apache2.conf there is an Include /etc/apache2/sites-enabled directive. Comment this out and replace it with Include /etc/apache2/vhosts.conf
now, with your favorite editor create a file /etc/apache2/vhosts.conf.
In this file, the first line will be NamedVirtualHost <Some IP you have> where <Some IP you have> is an actual interface's IP address (if you are NATing, use your internal address).
the following lines should follow the normal VirtualHost Directives like:
Code:

NameVirtualHost 192.168.254.4
#################### Start SomeSite.com Vhost #####################

<VirtualHost 192.168.254.4>
    DocumentRoot /var/www/SomeSite
    ServerName SomeSite.com
    ServerAlias www.SomeSite.com
    ErrorLog /var/log/apache/SomeSite.com-error.log
    CustomLog /var/log/apache/SomeSite.com-access.log combined
    Options FollowSymLinks MultiViews
</VirtualHost>

#################### End SomeSite.com Vhost ########################

#################### Start SomeOtherSite.com Vhost #####################

<VirtualHost 192.168.254.4>
    DocumentRoot /var/www/SomeOtherSite
    ServerName SomeOtherSite.com
    ServerAlias www.SomeOtherSite.com
    ErrorLog /var/log/apache/SomeOtherSite.com-error.log
    CustomLog /var/log/apache/SomeOtherSite.com-access.log combined
    Options FollowSymLinks MultiViews
</VirtualHost>

#################### End SomeOtherSite.com Vhost ########################

The ErrorLog and CustomLog directives make mgmt easier and you will also add any other directives (Like SSL stuff) in the vhosts.conf

I hope this helps... please feel free to comment and complain.


All times are GMT -5. The time now is 03:21 PM.