|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
This sounds like a dumb question, but I need to ask it anyway.
How do I host two web sites from the same box? I know that servers all over the country do this, but I don't know how to work out the IP stuff. I have a static IP of 123.123.123.123 that all port 80 requests go to. From there what do I do? How does the server know which page to serve? tia. |
|
#2
|
|||
|
|||
|
You need to use the <VirtualHost> directive of apache, it's at the end of your httpd.conf file, just add both domains to it with whatever other arguments you want to include. You'll also need to set up the dns info if you're the dns server.
terry [Edited by tlthomas on 03-03-2001 at 12:41 PM] |
|
#3
|
|||
|
|||
|
Even with the VirtualHost directive, how does the computer know that a request coming to my sole IP is meant for one site or another?
|
|
#4
|
|||
|
|||
|
That's what the VirtualHost directive does, if a request comes in for site "A" it delivers info from that sites directory (DocumentRoot), if a request comes in for site "B" it delivers from its directory and so on...
|
|
#5
|
|||
|
|||
|
Forgive me for being a little thick-skulled about this, but I'm still not clear on the process.
If my machine will only responds to requests sent to say 24.45.56.67 - how will it know that the user making a call to that IP wants to see Site A vs Site B? This gets back to domain registration, I beleive. With register.com I have to provide DNS servers for each site registered. This leads to two additional questions. 1) What would I list as my DNS server for a site on my local machine? 2) How does that information (the DNS server entered on register.com) help my computer know which pages to serve? Thanks for your patience ![]() |
|
#6
|
|||
|
|||
|
http://httpd.apache.org/docs/vhosts/examples.html
Apache provides several examples on the page. I thought I'd be using Setup2 in the first section, but I see that is for situations involving domain.com and sub.domain.com. That is good to know, however I'll be working with domain.com and otherdomain.com. The only examples they provided were for dual IP machines. ![]() |
|
#7
|
|||
|
|||
|
The <VirtualHost> directive can be set to be IP based or to be URI based.
To set up virtual hosts based on FQDN (Fully qualified domain names) .. set up the httpd.conf to contain info about each VHost like this: NameVirtualHost 123.123.123.123 <VirtualHost 123.123.123.123> ServerName http://www.firstdomain.com ServerAdmin yourname@firstdomain.com DocumentRoot /path/firstdomain ErrorLog /path-to-logs/errorlog.first {all other directives} </VirtualHost> <VirtualHost 123.123.123.123> ServerName http://www.seconddomain.com ServerAdmin yourname@seconddomain.com DocumentRoot /path/seconddomain ErrorLog /path-to-logs/errorlog.second {all other directives} </VirtualHost> or something simmular to this. you can put any directive in each VHost (directory, security, etc) When the httpd server starts ... it will listen to 123.123.123.123. When a request comes in it will look at the URL and direct it to the appropriate pages. You will also need to set the DNS entries for each FQDN in each of the DNS zones. in the zone for firstdomain.com www 123.123.123.123 in the zone for seconddomain.com www 123.123.123.123 |
|
#8
|
|||
|
|||
|
Question... is your isp pointing your domain toward your ip or are you running a dns server on your machine? If your isp is pointing they need to change their dns server to point the new (#2) domain toward your ip too, also in ref. to Hokey, are you running a windows server or a linux/unix server because there are various things that are different about dns servers depending on the os
terry |
|
#9
|
|||
|
|||
|
>> how will it know that the user making a call to that IP wants to see Site A vs Site B?
You don't tell people to go to your site at: http://123.123.123.123/. Instead, you tell them the domain name http://www.firstdomain.com and http://www.seconddomain.com. But still, when people are trying to reach your site via http://123.123.123.123/, they can still get to your http://www.firstdomain.com/ >> 1) What would I list as my DNS server for a site on my local machine? How many static IP do you have? >> 2) How does that information (the DNS server entered on register.com) help my computer know which pages to serve? Your nameserver can take care of that. It depends on how many static IP you have. Say your box is named "www.firstdomain.com", you can add an A record of that to your nameserver that points to 123.123.123. For http://www.seconddomain.com, you can also add an A record pointing to the same IP (123.123.123.123). Forget about PTR record (for reverse lookup), most ISP won't let you delegate the 123.123.123.123.in-addr.arpa. yourself. You probably get confused by now, so here is a short answer: Get both http://www.firstdomain.com and http://www.seconddomain.com to resolve to 123.123.123.123, then you may begin to configure Apache. If you can't do this, just give it up or change ISP. |
|
#10
|
|||
|
|||
|
I have been having a sililar problem for some time, and I'm completely unable to pass this one hurdle. I use Apache on a Windows 2000 box.
I have three domains which are all registered through register.com. I use their DNS servers. They all point to my external IP address of 123.123.123.123. I have a Linksys DSL router which is mapped to that external IP, and forwards port 80 requests to one of the computers behind the Linksys. The Linksys acts as a DHCP server, so the actual machine with Apache loaded has an IP of 192.168.1.101, and gets the port 80 requests. Here is my current setup... NameVirtualHost 123.123.123.123 <VirtualHost 123.123.123.123> ServerName URL ServerAdmin yourname@firstdomain.com DocumentRoot /firstdomain </VirtualHost> <VirtualHost 123.123.123.123> ServerName URL ServerAdmin yourname@seconddomain.com DocumentRoot /seconddomain </VirtualHost> <VirtualHost 123.123.123.123> ServerName URL ServerAdmin yourname@seconddomain.com DocumentRoot /thirddomain </VirtualHost> My default directory to serve files from is the htdocs directory, and I have subdirectories of firstdomain, seconddomain and thirddomain in the htdocs directory. I cannot get URL to pick up the docs in the firstdomain subdirectory. It ALWAYS defaults to the root htdocs directory. I have tried several things, but I can't get it past this point. I really feel like I'm close to successfully hosting these three domains, and am at the end of my ideas. Anyone have any suggestions as to what I'm doing wrong? Thanks for any help you can provide. |
|
#11
|
|||
|
|||
|
Hi, you need to put the full path to each DocumentRoot, replace
DocumentRoot /first(second, etc)domain with DocumentRoot c:/apache/home/htdocs/anydomain or whatever the full path is on your machine.... terry
__________________
It works better if you plug it in! |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > Serving two pages (domains) from one machine |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|