Virtual Host
Posted by: nunomira (---.37.54.77.rev.vodafone.pt)
Date: July 21, 2007 06:17PM

Hi,

I've read everything I could find - and I searched a lot - but I simply can't have a working virtual host.

in httpd.conf I have:

# Virtual hosts
Include conf/extra/httpd-vhosts.conf


And in httpd-vhosts.conf I have:

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot C:/wamp/www
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot C:/wamp/www/docs/myhost/
ServerName myhost
</VirtualHost>


I also have a folder C:/wamp/www/docs/myhost/ with an index.php file...

So, I'd expect to be able to go to [myhost] just like I go to [localhost], but it doesn't find the page and starts searching for myhost.com and so on...

Is there anything I'm missing?

And if I don't have

<VirtualHost *:80>
DocumentRoot C:/wamp/www
ServerName localhost
</VirtualHost>

going to [localhost] shows the page corresponding to C:/wamp/www/docs/myhost/index.php, i.e., what I'd expect to see going to [myhost]


So, I can't have [localhost] and [myhost]...
why?

Options: ReplyQuote
Re: Virtual Host
Posted by: nunomira (---.37.54.77.rev.vodafone.pt)
Date: July 21, 2007 06:55PM

Solved.

I also had to add the line

127.0.0.1 myhost

to my

C:\WINDOWS\system32\drivers\etc\hosts file (Windows XP Pro)

ending up with:
127.0.0.1 localhost
127.0.0.1 myhost


Now, when I go to [myhost] it work as expected.

Is this really necessary? Is this the only way?

Options: ReplyQuote
Re: Virtual Host
Posted by: nunomira (---.37.54.77.rev.vodafone.pt)
Date: July 21, 2007 07:36PM

I've also been able to create a .com virtual host:

<VirtualHost *:80>
DocumentRoot C:/wamp/www/docs/myhost.com
ServerName myhost.com
</VirtualHost>

and adding

127.0.0.1 myhost.com

to the hosts file

Now I can go to [myhost.com]

It seems that In order to use www: [www.myhost.com]

<VirtualHost *:80>
DocumentRoot C:/wamp/www/docs/myhost.com
ServerName www.myhost.com
ServerAlias myhost.com
</VirtualHost>

I also need to add

127.0.0.1 www.myhost.com

to the hosts file

Options: ReplyQuote
Re: Virtual Host
Posted by: dbood (---.wfd88a.dsl.pol.co.uk)
Date: July 22, 2007 10:49AM

hi

so if i wanted to host www.blah.co.uk instead of local host is the above what you do??

cheers dave

Options: ReplyQuote
Re: Virtual Host
Posted by: nunomira (---.26.54.77.rev.vodafone.pt)
Date: July 22, 2007 11:50AM

If you want a local copy of www.blah.co.uk exactly with the same address, for testing purposeses, that's what you do.

Notice that once you do it, you can't access the real www.blah.co.uk on the internet.
One solution is editing the hosts file.
Another is just using www.blah.co.uk or just blah.co.uk, but not the two. So, www.blah.co.uk would be the local address and blah.co.uk would be address on the internet


But if you want to have your computer serving www.blah.co.uk, you'll have to read the unofficial manual, as there are other steps involved and I guess that editing the hosts file isn't one of them.
The instructions are under "Setting up Apache to use a Domain Name".

Options: ReplyQuote
Re: Virtual Host
Posted by: dbood (---.wfd88a.dsl.pol.co.uk)
Date: July 22, 2007 12:06PM

Many thanks mate

cheers dave

Options: ReplyQuote
Re: Virtual Host
Posted by: CyberSpatium (71.237.217.---)
Date: July 22, 2007 03:20PM

see the post i made on my Web Development for Newbies Blog on virtual host.


CyberSpatium
----------------------
WAMP English Forum Admin

Need help? Check out my WAMP User Manual/Guide here!


Cellular Phone Deals - The Best on the Net! - FREE PHONES! Take your pick from our featured cellular phone deals by Cingular, Verizon, T-Mobile, Sprint PCS, Nextel, and more! Most of our cellular phone offers include a FREE cellular phone with FREE shipping!


Web Development for Newbie's Blog - Check out my new blog. It is for web developers, and especially tailored for the web development newbie. If you are not fluent in “geek speak”, then this incredible resource is just you. And even if you are a web development pro, this is a great resource to check out some of the latest web development tips, news, tutorials, codes and more.


Clarify Loans
Mortgage and Home Loan Advice


LaxGo Web Directory
Powerful human edited web directory of quality, spam-free sites organized via a comprehensive category structure.

Options: ReplyQuote


Sorry, only registered users may post in this forum.