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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache virtual hosts & one stressed out me 1

Status
Not open for further replies.

Tracey

Programmer
Oct 16, 2000
690
NZ
Hi

I have been trying to sort this one for months...
I have virtual hosts running fine on my local machine:

httpd.conf:

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
ServerName localhost
ServerAdmin tracey@XXX.co.nz
DocumentRoot "C:/Apache2/htdocs"
ScriptAlias /cgi-bin/ "C:/Apache2/cgi-bin/"
</VirtualHost>


<VirtualHost 127.0.0.1>
ServerName osmos.localhost
ServerAlias osmos.localhost
ServerAdmin tracey@XXX.co.nz
DocumentRoot "C:/Apache2/osmos"
ScriptAlias /cgi-bin/ "C:/Apache2/cgi-bin"
</VirtualHost>


hosts:
127.0.0.1 localhost
127.0.0.1 osmos.localhost


But when I try to get virtual hosts working on my web server, It still directs me to the main web site... [cry]

HTTPD.conf

NameVirtualHost 210.54.XXX.XXX

<VirtualHost 210.54.XXX.XXX>
ServerName etime.XXX.co.nz
ServerAdmin tracey@XXX.co.nz
DocumentRoot "C:/Apache2/htdocs"
ScriptAlias /cgi-bin/ "C:/Apache2/cgi-bin/"
</VirtualHost>

<VirtualHost 210.54.XXX.XXX>
ServerName osmos.XXX.co.nz
ServerAlias osmos.XXX.co.nz
ServerAdmin tracey@XXX.co.nz
DocumentRoot "C:/Apache2/osmos"
ScriptAlias /cgi-bin/ "C:/Apache2/osmos/cgi-bin"
</VirtualHost>


Hosts:

127.0.0.1 localhost
210.54.XXX.XXX etime.XXX.co.nz
210.54.XXX.XXX osmos.XXX.co.nz


Like I say, I have been trying to get this to work off and on for many months and have still not found an answer.. PLEASE can someone here point me to what is wrong?? My site goes commercial soon and I really need this done... [flame]

Cheers in advance [cheers]

Tracey




Tracey
Remember... True happiness is not getting what you want...

Its wanting what you have got!
 
Fist question: Is that IP address (210.54.XXX.XXX) bound to your local ethernet adapter? Or does your ethernet adapter have a private IP address (like behind a router)?
 
To edit httpd.conf the best possible way is to use apache admin ( ApacheAdmin ). Its a httpd.conf gui from hqware with IIS admin like interface. you can download it from I just started using it and find it comfortable.
 
Hi smah,

that ip address is bound to my adsl router. The NIC in the server has a static IP (internal) I also have another nic in the machine for local network, however it is disabled. (it has occurred to me that maybe the 2nd card could cause some problems)

So in answer, the 2nd choice. Do you think I should be using the private IP?

apachenewbie
Unfortunately, although that product is cheap, my boss has a "pay nothing" policy. Thats why I'm using Apache on windows 2000 =) I might download the trial though, and see what it actually does.





Tracey
Remember... True happiness is not getting what you want...

Its wanting what you have got!
 
Change all of the 210.54.XXX.XXX references to your internal IP address. Apache has now way of knowing what your router's WAN IP address is. By default with named virtual hosts, if Apache can't figure out which host is being requested, it will serve up the first in the list.

BTW, is it a typo or is there no difference in ServerName & ServerAlias in the second VirtualHost listed?
 
O thanks. so easy to fix in the end.
BTW...
not a typo, is that wrong?

Tracey
Remember... True happiness is not getting what you want...

Its wanting what you have got!
 
It probably won't cause any problems, but it really doesn't do anything either. Typical use for ServerName & ServerAlias would be:

ServerName mydomain.com
ServerAlias
 
ok true, but what if you have no w's?

eg my URL is
Tracey
Remember... True happiness is not getting what you want...

Its wanting what you have got!
 
If you only one 'name' to access the site, then ServerAlias is unneccessary. This directive is only used if you need to access a particular virtual host by more than one name. Like I said, it probably won't cause any problems to leave it. A better usage example would be if you have multiple different domain names, but want some of them to serve the exact same content:

<VirtualHost *:80>
ServerName domain1.com
ServerAlias domain1.net domain2.com # Other stuff
</VirtualHost>
 
ah. ok thanks smah

Tracey
Remember... True happiness is not getting what you want...

Its wanting what you have got!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top