multiple Domains on one IP address

Can some one explain to me how i can setup multiple domain names on one ip address ??  I'm running RedHat 6.1 and I'm running the latest Apache.
LVL 1
ttrogdenAsked:
Who is Participating?
 
munsieConnect With a Mentor Commented:
well, first you need to have your DNS setup to point to that address for each of domains.

Then, for each virtual domain, you need to add a section to your configuration file

for example, to have www.abc.com and www.xyz.com, you can do the following:

NameVirtualHost xx.xx.xx.xx   <-- machine's ip address

<VirtualHost xx.xx.xx.xx>
ServerName www.abc.com
ServerPath /abc
DocumentRoot /home/httpd/www.abc.com
</VirtualHost>

<VirtualHost xx.xx.xx.xx>
ServerName www.xyz.com
ServerPath /xyz
DocumentRoot /home/httpd/www.xyz.com
</VirtualHost>

You can stick any additional options for each site into the VirtualHost section and you can place default options for all of the sites into the main server section.
 
The ServerPath directive allows for compatibilty with older HTTP/1.0 browsers, so that they can still access all of the different servers.  What you will need to do is on the primary hostname's web page, place links to http://www.primary.name.com/virtual_name/ for each of the sites.  If you don't do this, you might close out users of older browsers.

For more info, goto www.apache.org, but this should get you going.

good luck,
dennis
0
 
ttrogdenAuthor Commented:
Now - I want to have these domain names share the same server/Ip address.  Also the server is also the DNS server.  Will this work ??


0
 
munsieCommented:
yes, to sum it up

in your DNS, you'll add a alias/CNAME to your DNS for each virtual host you want.

when you do a lookup on the virtual name, it will resolve to your one IP address.  If you do a reverse name lookup, it will come back with the main server name.

apache keys off the host name sent with the http request and serves the proper page.

dennis
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
ttrogdenAuthor Commented:
ok - For our documentroot - can it be /home/abc/public_html and /home/xzy/public_html

or does it have to be in /home/httpd/abc and /home/httpd/xyz

I'm sorry to be so naive about this.


Tommyt
0
 
munsieCommented:
it can be anywhere you want it on the system...

i was just using /home/httpd because RedHat defaults to using that as it's http directory.

actually, i can see where /home/abc/public_html would be more useful, because you can give the owner of that site a login and let them change things on their own.

but to answer the question, it will work... just make sure that user nobody can read files in that directory (just 'su - nobody', and verify that you can see all of the files)

dennis
0
 
munsieCommented:
it can be anywhere you want it on the system...

i was just using /home/httpd because RedHat defaults to using that as it's http directory.

actually, i can see where /home/abc/public_html would be more useful, because you can give the owner of that site a login and let them change things on their own.

but to answer the question, it will work... just make sure that user nobody can read files in that directory (just 'su - nobody', and verify that you can see all of the files)

dennis
0
 
ttrogdenAuthor Commented:
ok I hope this is the last question for you.  BTW - your getting an A on this one - thanks a bunch fro your help.  On that note - what file do i have to add that stuff to ??


tommyt
0
 
ttrogdenAuthor Commented:
ok - i created the virtual servers in the httpd.conf the way you described it above - now you said for me to make some changes in the dns - can you give more details of how i should do this
0
 
munsieCommented:
I know you need to add the CNAME record for the host, but I don't know exactly what that entails... i would recommend looking at the DNS-HOWTO... if you installed everything under RedHat, this will be located in /usr/doc/HOWTO/DNS-HOWTO

good luck,
dennis

0
 
ttrogdenAuthor Commented:
thanks for the help
0
 
munsieCommented:
no problem

dennis
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.