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

Virtual Hosts

Status
Not open for further replies.

ralphiooo

Programmer
Oct 23, 2005
64
GB
Hi, I have set up my server successfully to run php with mysql. When I goto it works fine but the trouble is I've got lots of sites which I use relative linking for. I just want to use apache as a testing server and I understand you can use virtual hosts to help with multiple sites but I don't understand how I can do this without a domain name. I'd appreciate your help.

Thanks
 
Hi

The simpliest way is to just add the virtual host names to the hosts file. For this virtual hosts :
Code:
NameVirtualHost *

<VirtualHost *>
  ServerName test
  DocumentRoot /home/feherke/testing
</VirtualHost>

<VirtualHost *>
  ServerName demo
  DocumentRoot /home/feherke/demo_docs
</VirtualHost>
In /etc/hosts I have this :
Code:
127.0.0.1    localhost test demo
Evidently with this only my computer will know about the virtual hosts, the others not.

Feherke.
 
Hi, cheers I tried:

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
DocumentRoot U:/My Webs/ ServerName test1.local
</VirtualHost>

<VirtualHost 127.0.0.1>
DocumentRoot U:/My Webs/ ServerName test2.local
</VirtualHost>

and changed the hosts file to:

127.0.0.1 localhost
127.0.0.1 test1.local
127.0.0.1 test2.local

but when I do a restart in apache i get an error. I also tried the * instead of 127.0.0.1 but I get the same error "The request operation has failed".

Appreciate your help once more. Thanks
 
Apache 2.0 Vitural Host Fix:

I use DHCP through comcast and here is how I did it.

#The ip address is a must so is the port
NameVirtualHost your ip address:80


#Notice the port and the slash direction they are very improtant!


<VirtualHost ServerName DocumentRoot /htdocs/website1
ServerAdmin webmaster@website1.com
</VirtualHost>


<VirtualHost ServerName DocumentRoot /htdocs/website2
ServerAdmin webmaster@website2.com
</VirtualHost>

<VirtualHost ServerName DocumentRoot /htdocs/website3
ServerAdmin webmaster@personalrmc.com
</VirtualHost>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top