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!

DNS 4 subdomains?

Status
Not open for further replies.

Neutje

Programmer
Sep 19, 2001
38
0
0
BE
Hi,

How do I have to configure the dns setting to use subdomains on Apache ?

--
Neutje
neutje@hotmail.com
<<--- if it doesn't work, its because of the subdomain
probs I have...
 
Hi,

I presume you are talking about name based virtual hosts. All you do is edit your httpd.conf file and add something like this:

NameVirtualHost 172.16.16.1
<VirtualHost 172.16.16.1>
UseCanonicalName off
ServerName DocumentRoot /var/</VirtualHost>
<VirtualHost 172.16.16.1>
UseCanonicalName off
ServerName DocumentRoot /var/</VirtualHost>
<VirtualHost 172.16.16.1>
UseCanonicalName off
ServerName DocumentRoot /var/</VirtualHost>

You put the site content in the relevant 'DocumentRoot' directory set up dns for the servernames to resolve to the same ip address, i.e 172.16.16.1 in the above example. When a request is received, apache examines the http header for the ' part and serves up the appropriate content. It's pretty easy really.

See also -->
Rgds
 
I think he means a subdomain like:
webone.mysite.com and webtwo.mysite.com.
You do not need to have dns for that, but It would probably provide you and website viewers with faster access.

Just set up a virtualhost container like ifincham said.

<VirtualHost 192.168.0.12>
ServerName webone.mysite.com
DocumentRoot /httpd/html/webone-sub
</VirtualHost>

Make sure to set the IP and NameVirtualHost directives properly, and make sure you use the right IP addressing whether you are behind a firewall or not. Rninja

smlogo.gif

 
I think everyone helped out here.
Here's what I would do. If anyone thinks this is incorrect, please let me know:

NameVirtualHost YOUR_SERVER_IP
<VirtualHost YOUR_SERVER_IP>
ServerAdmin email_address
DocumentRoot path_to_home_directory
ServerName subdomain.domain.com
</VirtualHost>
<VirtualHost YOUR_SERVER_IP>
ServerAdmin email_address2
DocumentRoot path_to_home_directory2
ServerName subdomain2.domain.com
</VirtualHost>
<VirtualHost YOUR_SERVER_IP>
ServerAdmin email_address3
DocumentRoot path_to_home_directory3
ServerName subdomain3.domain.com
</VirtualHost>

Hope that works out for ya!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top