網上方法五花白門,特意記錄一下,需要的朋友自行拿去就好。
需要修改的文件:httpd.conf / httpd-vhosts.conf / hosts
對應路徑:
httpd.conf:wamp\bin\apache\Apache2.2.21\conf
httpd-vhosts.conf:wamp\bin\apache\Apache2.2.21\conf\extra
hosts:c\Windows\System32\drivers\etc
修改流程:
1,打開httpd.conf,約466行:#Include conf/extra/httpd-info.conf,刪除#;
2,還是httpd.conf,約188行:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
改為:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
#Deny from all
Allow from all
#允許所有訪問
Satisfy all
</Directory>
3,打開httpd-vhosts.conf,在最下方空白處添加以下代碼(自行修改wamp安裝路徑):
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "f:/wamp/www"
ServerName localhost
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "f:/wamp/www2"
ServerName www2.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
4,最後一步:打開hosts文件,在最後一行下面添加以下代碼:
127.0.0.1 localhost
127.0.0.1 www2.com
重啟wamp之後,localhost與www2.com即可區分開發,多站點配置成功。