One of the main reasons virtual host was included in apache was so one server, with one ip address could host unlimited websites with that one ip instead of having to use an ip for every website. The port has nothing to do with virtual hosting, so do not change that. If only you are going to be accessing your wamp sites, you can just edit your windows hosts file:
open:
C:\WINDOWS\system32\drivers\etc\hosts (open this with NotePad, not WordPad or MS Word)
Towards the bottom of the file, you will see:
127.0.0.1 localhostBelow that add:
127.0.0.1 testsite1.com
127.0.0.1 testsite2.comSave the file. Open up apache conf file
httpd.conf (again with Notepad,not with WordPad or MS Word)
C:\wamp\Apache2\conf\httpd.confFind this line:
#NameVirtualHost *:80Change it to:
NameVirtualHost *:80
#
#### testsite1.com ####
#
<VirtualHost *:80>
ServerAdmin webmaster@testsite1.com
DocumentRoot C:/wamp/users/www.testsite1.com/public_html
ServerName www.testsite1.com
ServerAlias testsite1.com
ErrorLog C:/wamp/users/www.testsite1.com/logs/error.log
CustomLog C:/wamp/users/www.testsite1.com/logs/access.log common
<Directory "C:/wamp/users/www.testsite1.com/public_html">
Options Indexes FollowSymLinks Includes
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
#
#### testsite2.com ####
#
<VirtualHost *:80>
ServerAdmin webmaster@testsite2.com
DocumentRoot C:/wamp/users/www.testsite2.com/public_html
ServerName www.testsite2.com
ServerAlias testsite2.com
ErrorLog C:/wamp/users/www.testsite2.com/logs/error.log
CustomLog C:/wamp/users/www.testsite2.com/logs/access.log common
<Directory "C:/wamp/users/www.testsite2.com/public_html">
Options Indexes FollowSymLinks Includes
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>Save the file, and restart apache for the new settings to take effect. Note that the
allow from 127.0.0.1 setting from above is for security reasons, is means only you can access this site. If you move your test sites to an actual live web server, change it to
allow from all.
Also to get this to work for you, crate a folder in your wamp directory (
c:\wamp) called
users. This new folder is where all your virtual hosted websites will be saved. Now create a folder in the users folder called
www.testsite1.com. In the
www.testsite1.com folder, create two new folders, one called
pubic_html where all your website files for testsite1 will go, and create a folder called
logs, this is where you apache logs will go.
Now go back to the users directory, and create a new folder called
www.testsite2.com. Go to that new folder and again, create a
public_html folder and a
logs folder.
You will now save all your html, php, images, ccs, and all other website files for testsite1.com in:
c:\wamp\users\www.testsite1.com\public_htmlAnd you will save all your website files for testsite2.com in:
c:\wamp\users\www.testsite2.com\public_htmlTo see your sites in action, open up your web browser and go to:
http://www.testsite1.com
[www.testsite2.com]Please note that I use
testsite1.com and
testsite2.com here in all these examples. Replace them with your actual domain name (google.com for example). You can also add more domains by adding it to the virtual host section of your
httpd.conf file, and creating a new directory for that site in the
users folder like in the previous example.
You can also set wamp to be accessible by others then yourself. Be careful thought, as wamp was designed for local testing and development only , not for a live production server. It has absolutely no security in place. But it can be done.
You will need to delete the
testsite1.com and
testsite2.com part we just added to windows
hosts file. Now edit the
httpd.conf file, and change all
allow from 127.0.0.1 to
allow from all. Save the file and restart apache for the new settings to take effect.
To make your site accessible to others, we will have to setup DNS for you domains. Sign up for a free dynamic ip address service.
www.zoneedit.com is one of the most popular on the net. I prefer
www.everydns.net myself.
After you create your accounts, add your domains. After you add a zone, you will need to setup two
A records to tie your domain name to your ip address:
testsite1.com your.ip.address.here
www.testsite1.com your.ip.address.hereNow add your other domain and then add two
A records for that domain to
testsite2.com your.ip.address.here
www.testsite2.com your.ip.address.herenow anyone can access you wamp by using:
http://www.testsite1.com
[www.testsite2.com]Post Edited (05-28-06 23:47)
CyberSpatium----------------------WAMP Forum Admin
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.