Virtual Hosting?
Hello,
Just about to set up two websites on my new server, but im new to setting up virtual hosts so i need help... Lets say my real IP address is 123.4.5.6 and that im running my first website on it. Now the problem comes with my second website and second IP. Look at this <VirtualHost 123.4.5.7> ServerAdmin admin@mysite.com DocumentRoot /home/mysite/public_html ServerName www.mysite.com ErrorLog /home/mysite/logs/error_log CustomLog /home/mysite/logs/access_log common </VirtualHost> Notice that i increased 6 to 7 at the end of the IP address... Can I do this??? what if someone else has that IP address??? Can someone else have that IP address?? Using the example above every time I try to access the second website typing http://123.4.5.7/ in the browser I get "This document contains no data" as an error..... and then blank page... Accessing my first site on http://123.4.5.6/ is no problem.... I placed an test index.html file in /home/mysite/public_html just in case but i still get the same result :( Anyone know how to solve this? Thank you. |
no, you can't change the IP like that unless both IP's point to your server, for each virtualhost just set 'ServerName' to the domain, so for one it may be www.domain1.com and the second virtualhost may have ServerName set to www.domain2.com
|
If your sites are on the same server.. don't even bother with specifying the IP address in the Virtual hosts section..
<VirtualHost *> <= should work just fine and to clarify, no you can't just make up IP addresses.. :rolleyes: |
Okay, this is how i did it now:
<VirtualHost 123.4.5.6> ServerAdmin admin@mysite1.com DocumentRoot /home/mysite1/public_html ServerName www.mysite1.com ErrorLog /home/mysite1/logs/error_log CustomLog /home/mysite1/logs/access_log common </VirtualHost> <VirtualHost 123.4.5.6> ServerAdmin admin@mysite2.com DocumentRoot /home/mysite2/public_html ServerName www.mysite2.com ErrorLog /home/mysite2/logs/error_log CustomLog /home/mysite2/logs/access_log common </VirtualHost> But i get this warning after restarting the server: Stopping httpd: [ OK ] Starting httpd: [Tue May 31 20:19:13 2005] [warn] VirtualHost 123.4.5.6:0 overlaps with VirtualHost 123.4.5.6:0, the first has precedence, perhaps you need a NameVirtualHost directive [ OK ] Not sure what that means?? What do I do?? Thx |
Get rid of the IP address and use a *
|
ah okay, i have been reading alot and found out that Virtual Hosting needs separate IP addresses for each website... and since I only have one address I need to create my own virtual IP adresses (IP aliace)........ In that case, replacing the IP as some of you mention above with a * wont to the job will it??
I did replace it with a * and got the same warning message as I explained above.... Does anyone know how to make virtual IP adresses?? I tried to find a Fedora documentation but failed doing so... |
Ok, stop worrying about having additional IP's or virtual IP's.. etc..
Try doing this instead: <VirtualHost *:80> And did you actually test your sites despite that error? |
If you have one 1IP and want to run more than one website you must use name-based virtual hosts.
you should read the following links http://httpd.apache.org/docs-2.0/en/vhosts/ http://httpd.apache.org/docs-2.0/en/...ame-based.html http://httpd.apache.org/docs-2.0/en/.../examples.html http://httpd.apache.org/docs-2.0/en/.../ip-based.html |
Add 'NameVirtualhost 123.4.5.6' to httpd.conf.
It just means 'Requests to this ip address will be categorized by the hostname they ask for'. You can have a million web sites on a single ip address, as long as their names are different. The names need to be put into dns, or into the 'hosts' file on the client's computer, or else the client won't know what ip address to go to. |
Okay, I basically got it all figured out now, just have a few more questions:
Using IP-based hosting, I can only, and I mean ONLY run ONE website under one IP address correct? IF I can run more then ONE website on an IP-based hosting, please explain HOW :) I choose to use IP-based hosting because I need the SSL later... so I wont be using Name-based hosting... Thx :study: |
For each IP-based virtual host you need one IP and there can be only one web. It is also not possible to use Name-Based Virtual Hosting to identify different SSL virtual hosts. You must use for every SSL site with his own certificate a new IP-based virtual host (or a different Port). Have a look at http://httpd.apache.org/docs-2.0/ssl...q.html#vhosts2
|
All times are GMT -5. The time now is 04:58 AM. |