Welcome to WebmasterWorld Guest from 188.8.131.52 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
name-based virtual hosting on apache zamnik msg:915827 9:00 am on Feb 28, 2003 (gmt 0) I need to configure two different web site on one IP. What ammendment should i do on the httpd.conf and my DNS server?
hakre msg:915828 9:06 am on Feb 28, 2003 (gmt 0)
the apache group has this in their docs for apache webserver. there is an intro on the topic in a whole article. it's called
Apache Virtual Host documentation [ httpd.apache.org].
i think you should read this. anyway, for domain name based virtual hosting, the following directives are used:
... Port 80 ServerName server.domain.tld
DocumentRoot /www/domain ServerName www.domain.tld ... </VirtualHost> <VirtualHost *> DocumentRoot /www/subdomain ServerName www.sub.domain.tld ... </VirtualHost>
this example is taken out of the docs and handles a toplevel domain and a subdomain. but much more is possible, ie you could setup multiple domains in one virtualhost section.
zamnik msg:915829 12:59 am on Mar 1, 2003 (gmt 0)
thanks for the links. any configuration i need to do on my DNS server and how? thanks again dingman msg:915830 8:54 pm on Mar 1, 2003 (gmt 0)
DNS just needs to resolve both domain names to the IP of your server. That's it. zamnik msg:915831 12:10 am on Mar 3, 2003 (gmt 0)
So, it's only to deal with httpd.conf for setting up name-based virtual server on apache? dingman msg:915832 12:42 am on Mar 3, 2003 (gmt 0)
Assuming a BIND name server and Apache:
in your zone file:
* IN A 184.108.40.206 IN HINFO "p166mmx" "Debian 3.0" @ IN A 220.127.116.11 IN HINFO "p166mmx" "Debian 3.0"
NameVirtualHost 18.104.22.168:80 <VirtualHost example.com:80> ServerAdmin email@example.com DocumentRoot /var/www/www.example.com ServerName www.example.com ServerAlias example.com </VirtualHost> <VirtualHost devel.example.com:80> ServerAdmin firstname.lastname@example.org DocumentRoot /var/www/devel.example.com ServerName devel.example.com </VirtualHost> <VirtualHost other.example.com:80> ServerAdmin email@example.com DocumentRoot /var/www/other.example.com ServerName other.example.com </VirtualHost>
These are based on my own working zone file and httpd.conf fragments, munged to fit example.com rather than my own domain and IP addresses. The ":80" that shows up in my httpd.conf could be omitted in many circumstances - in my configuration it can't, because port 443 uses IP-based virtual hosts. (I've got more virtual hosts than you can shake a stick at.) The "DocumentRoot" paths are purely hypothetical, and should match whatever directory you're keeping the files in for that vhost. The zone file fragment would expect to be used for the zone 'example.com'.