vhosts advice needed
Posted by: wollombiwombat (---.lnk.telstra.net)
Date: February 22, 2012 08:15AM

Hi all

Well, yesterday I downloaded and installed wampserver2.2c-x64 on my new Win7 64bit config.

All works as advertised up to a point. I would like to congratulate and thank the developers for this neat creation which takes a considerable amount of time out of what would be required to install Apache, PHP, MySQL and phpMyAdmin.

I have so far been successful in setting up a couple of sites under C:\wamp\www

My question concerns the use of vhosts. I have setup a site as follows in http-vhosts.conf

<VirtualHost *:80>
DocumentRoot "C:/vhosts/test-site-1"
ServerName test-site-1
</VirtualHost>

This test site includes a single file - index.php which includes the phpinfo(); call on PHP.

I have removed the comment in the line shown below

Include conf/extra/httpd-vhosts.conf

in the httpd.conf file,

Another thing I have done is to edit the index.php file in c:\wamp\www to point to my vhosts directory which is at c:\vhosts Therefore the line 20 now is:

$vhostsDir = '../../vhosts/';

I restarted Apache, then when I attempt to visit the site directly in the browser via [test-site-1], I get a browser message telling me that the site cant be found.

Not only that, but when I attempt to visit a site at [localhost] that was working before I edited the httpd.conf file, I get a 403 error message telling me that I dont have permission to access the site on this server.

I have gone over and over everything, but cant figure out the basic blunder I must be making. :-((

Any suggestions would be greatfully received. :-)

TIA

Options: ReplyQuote
Re: vhosts advice needed
Posted by: RiggsFolly (---.as13285.net)
Date: February 29, 2012 11:38PM

The problem is you PC does not know where to find the urls you are using.

First you need to amend your hosts file.

Without adding the site names to your hosts file there is no way that the site name that you enter into the browser can be translated to an ip address. Hosts acts as a sort of local DNS and is checked first before going out to a real DNS server.

run your editor "as Administrator" or you will not be allowed to save changes to hosts file.

host is in c:\windows\systems32\drivers\etc it is called hosts ( with no extension )


Add lines like this:

127.0.0.1 site1.localhost
127.0.0.1 site2.localhost


If you want to run your web server on another machine then do it like this,
192.168.0.250 site3.testing



setup your httpd-vhosts.conf as follows

## must be first so the the wamp menu page loads
<VirtualHost *:80>
ServerAdmin webmaster@.localhost
DocumentRoot "D:/wamp/www"
ServerName localhost
ServerAlias localhost
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@.localhost
DocumentRoot "D:/websrc/test-site-1"
ServerName site1.localhost
ServerAlias site1.localhost
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@.localhost
DocumentRoot "D:/websrc/test-site-2"
ServerName site1.localhost
ServerAlias site2.localhost
</VirtualHost>


and add as many as you like. My wamp is on the D:\ drive so if yours is on C:\ change the references acordingly.


Once this is all done you need to restart the "DNS Client" service.
Do this again from a command prompt run "as Administrator" as follows
>net stop "DNS Client"
Wait for the message saying its stopped
>net start "DNS Client"


Restart all Services from WAMP Manager and restart a new browser and all should be HumkyDory.



You can access your site as site1.localhost, site2.localhost and site3.testing.
I use the .localhost to remind me I am working locally but you can use pretty much any word you like or just site1 and site2 if you prefer.

Options: ReplyQuote


Sorry, only registered users may post in this forum.