1. Mở file C:\Windows\System32\drivers\etc\hosts, thêm vào:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 site1.com #My Test Site
127.0.0.1 site2.com #My Test Site
2. Vào /wamp/www/, tạo thư mực site1 và site2 trong
3. Mở file /wamp/bin/apache/apache2.2.22/conf/httpd.conf
Lưu ý dòng cuối cùng của file đang là Include "/wamp/alias/*"
Sửa "Listen 80" thành "Listen *:80" hoặc "Listen 0.0.0.0:80
Bỏ comment tại
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Comment để tránh lỗi 403 forbidden
#<Directory />
# AllowOverride none
# Require all denied
#</Directory>
4. Open conf/extra/httpd-vhosts.conf, khai báo các virtual hosts theo cách bên dưới
<VirtualHost *:80>
ServerAdmin admin@site1.com
DocumentRoot "D:/working/wamp/www/site1"
ServerName site1.com
ErrorLog "logs/site1.com-error.log"
CustomLog "logs/site1.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin@site2.com
DocumentRoot "D:/working/wamp/www/site2"
ServerName site2.com
ErrorLog "logs/site2.com-error.log"
CustomLog "logs/site2.com-access.log" common
</VirtualHost>
Nếu thư mục không nằm trong /wamp/www/ thì cần add như sau:
<VirtualHost *:80>
DocumentRoot "C:/site3"
ServerName site3.com
<Directory "C:/site3">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
5. Restart wamp
6. Truy cập http://site1.com, http://site2.com