Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache Configuration

Status
Not open for further replies.

Hawki

Programmer
Oct 16, 1999
63
0
0
US
Hi

Can someone please state in clear and understandable writing how do you configure Apache Server running Linux 7.1. I am looking at running Hosting virtual servers - one IP address but the material I have been reading seems vague. I have one IP Addresses four sites. Could you please explain DocumentRoot is pointing to.


<VirtualHost ip.address.of.host.some_domain.com>
# ServerAdmin webmaster@host.some_domain.com
# DocumentRoot /# ServerName host.some_domain.com
# ErrorLog logs/host.some_domain.com-error_log
# CustomLog logs/host.some_domain.com-access_log common
#</VirtualHost>

Thank you

Hawki
 
Hi,











OK.. What you are describing is known as name-based virtual hosting. The way it works is fairly simple. You arrange that all the sites you are going to host resolve via DNS to the same IP address, i.e. the address of the box running apache.











Once the requests are received by apache it examines the http header to see what domain was requested and based on that information in the header it serves up content from the relevant virtual host. This only works if the browser of the user is http 1.1 compliant or otherwise (as does Netscape 4.7) supports the Host field. Most modern browsers will be fine but a few oldies can cause problems because they don't provide this information on which apache selects the virtual host.











Within your httpd.conf file (probably /etc/httpd/conf/httpd.conf) you need directives like these :











NameVirtualHost 172.16.16.1











<VirtualHost 172.16.16.1>





UseCanonicalname off





ServerName vhost1.mydomain.com





DocumentRoot /var/




</VirtualHost>











<VirtualHost 172.16.16.1>





UseCanonicalname off





ServerName vhost2.mydomain.com





DocumentRoot /var/




</VirtualHost>











The NameVirtualHost directive defines the IP address to be used for virtual hosting. If you want you can replace the IP address references above with * which will match all interfaces on the server. Otherwise you would put the IP address of your internet connection. The 'ServerName' directive defines the domain to look for in the http header. For example would match the second one above. The 'DocumentRoot' directive simply defines where the html files and other content are physically stored on the server for that virtual host. So, for example, a request for would cause apache to look for /var/









The above examples use subdomains of the mydomain.com domain but it works the same for different actual domains - for example mydomain1.com & mydomain2.com - as long as they resolve via DNS to the ip address of the apache server.










Hope this is clear enough .
 
Maybe try this too

NameVirtualHost YOUR_SERVER_IP

<VirtualHost YOUR_SERVER_IP>
ServerAdmin email_address
DocumentRoot path_to_home_directory
ServerName domain.com
ServerAlias </VirtualHost>
<VirtualHost YOUR_SERVER_IP>
ServerAdmin email_address2
DocumentRoot path_to_home_directory2
ServerName domain2.com
ServerAlias </VirtualHost>

I've had problems using * instead of the ip address.
Don't know if this helped but if you still have probs, that could help ya.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top