Setting Up Multiple Websites/IPs

Installing, Configuring, Troubleshooting server daemons such as Web and Mail
Post Reply
bryceray1121
Posts: 2
Joined: 2010/09/25 21:24:25

Setting Up Multiple Websites/IPs

Post by bryceray1121 » 2010/09/25 21:28:21

I've currently got a centos server setup in my home. It has 1 website running on it and I am using DynDNS.com's service to access the server. DynDNS works by redirecting a free url to the IP address of your server. I would like to add a second website under a different url. However, I'm not sure how to add a second IP address (which I would then use with DynDNS to create a new url).

I've got some basic linux administration knowledge but I'm still learning and would appreciate any suggestions on approaches to this problem.

Thanks for your help.

scottro
Forum Moderator
Posts: 2430
Joined: 2007/09/03 21:18:09
Location: NYC
Contact:

Setting Up Multiple Websites/IPs

Post by scottro » 2010/09/25 23:10:51

Making the following assumptions.

(Take a look at https://www.centos.org/modules/newbb/viewforum.php?forum=47 as it gives hints on what to post when asking).

You have a dyndns site of john@homeunix.net

You have registered a domain example.com

You have registered a second domain johnexample.com

You've already set up example.com so if I go to example.com, it goes to the first site. You now want it so that if I go to johnexample.com, it goes to the second site.

Direct the second site to the same john.homeunix.net machine.

In httpd.conf, you need something like (things in brackets [] are comments)

[code]
<VirtualHost *:80>
ServerName www.johnexample.com:80
ServerAdmin webmaster@johnexample.com [assuming you've set up mail for it as well]
DocumentRoot /var/www/html/johnexamplesite
<Directory /var/www/html/johnexamplesite>
[whatever directory stuff you want, such as allow, deny, symlinks, etc.etc]
</Directory>
</VirtualHost>
[/code]

Hopefully, that's enough to get you started.

bryceray1121
Posts: 2
Joined: 2010/09/25 21:24:25

Re: Setting Up Multiple Websites/IPs

Post by bryceray1121 » 2010/09/26 16:04:45

I set my httpd.conf up like this:
[code]
<VirtualHost *:80>
ServerName domain1.dyndns.org:80
ServerAdmin webmaster@mydomain.org
DocumentRoot /home/www/public_html/domain1/
</VirtualHost>
<VirtualHost *:80>
ServerName domain2.dyndns.org:80
ServerAdmin webmaster@mydomain.org
DocumentRoot /home/www/public_html/domain2/
</VirtualHost>
[/code]

However, when I try to visit the URLs I get "Unable to connect" for both URLS. Did I follow your directions correctly? Or is there something else I should be considering.
Note: the original domain did not have a VirtualHost so I made one for both (should I just have made one for the second domain).

Thanks for your help.

scottro
Forum Moderator
Posts: 2430
Joined: 2007/09/03 21:18:09
Location: NYC
Contact:

Re: Setting Up Multiple Websites/IPs

Post by scottro » 2010/09/26 22:02:52

When I did it, I had both as virtual hosts. You will also need to be sure that NameVirtualHost is uncommented.

If it's still not working, I'd suggest Googling for a tutorial on setting up virtualhosts on Apache. (The Apache tutorial itself used to be typical, slipshod Linux documentation that didn't bother to mention various essentials, don't know if it's improved or not. )


You haven't mentioned if my original assumptions are correct--if they're not, then the instructions I gave are probably not good.

crittersmagic
Posts: 2
Joined: 2014/02/12 13:38:28

Re: Setting Up Multiple Websites/IPs

Post by crittersmagic » 2014/03/11 23:36:51

My question is this. My main website is set up on my main IP, if i am adding a second website and want it on a second IP. Do i need to bind my IP's or will the server listen for that IP once i set up vhosts.

scottro
Forum Moderator
Posts: 2430
Joined: 2007/09/03 21:18:09
Location: NYC
Contact:

Re: Setting Up Multiple Websites/IPs

Post by scottro » 2014/03/12 09:46:28

If each host has a separate IP then instead of

Code: Select all

<VirtualHost *:80>
Use the IP instead of the *, so that it's

Code: Select all

 
<VirtualHost 192.168.1.12:80>
New users should check the FAQ and Read Me First pages

Post Reply

Return to “CentOS 5 - Server Support”