Welcome to WebmasterWorld Guest from 18.104.22.168 , 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
I need to configure two different web site on one IP. What ammendment should i do on the httpd.conf and my DNS server?
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.
thanks for the links. any configuration i need to do on my DNS server and how? thanks again dingman
DNS just needs to resolve both domain names to the IP of your server. That's it. zamnik
So, it's only to deal with httpd.conf for setting up name-based virtual server on apache? dingman
Assuming a BIND name server and Apache:
in your zone file:
* IN A 22.214.171.124 IN HINFO "p166mmx" "Debian 3.0" @ IN A 126.96.36.199 IN HINFO "p166mmx" "Debian 3.0"
NameVirtualHost 188.8.131.52:80 <VirtualHost example.com:80> ServerAdmin firstname.lastname@example.org DocumentRoot /var/www/www.example.com ServerName www.example.com ServerAlias example.com </VirtualHost> <VirtualHost devel.example.com:80> ServerAdmin email@example.com DocumentRoot /var/www/devel.example.com ServerName devel.example.com </VirtualHost> <VirtualHost other.example.com:80> ServerAdmin firstname.lastname@example.org 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'.