koastal.com:90 映射到 127.0.0.1:90 ,对应路径 D:\schooloes
naruto.com 映射到 127.0.0.10 , 对应路径 E:\demo
hosts文件位置:C:\Windows\System32\drivers\etc\hosts
在文件最后添加以下内容:
127.0.0.1 koastal.com 127.0.0.1 www.koastal.com 127.0.0.10 naruto.com 127.0.0.10 www.naruto.com
httpd.conf文件位置:C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf
定位到:
# Virtual hosts #Include conf/extra/httpd-vhosts.conf
去掉注释符,修改为:
# Virtual hosts Include conf/extra/httpd-vhosts.conf
打开文件httpd.conf,定位到位置:
Listen 0.0.0.0:80 Listen [::0]:80
在下面添加一行
Listen 90
将httpd-vhosts.conf 内容清空,然后添加:
<VirtualHost 127.0.0.1:90> ServerAdmin [email protected] DocumentRoot "d:/schooloes" ServerName koastal.com ServerAlias www.koastal.com ErrorLog "logs/koastal.com-error.log" CustomLog "logs/koastal.com-access.log" common <Directory "d:/schooloes"> Options FollowSymLinks AllowOverride None Order deny,allow Require all granted </Directory> </VirtualHost>
打开httpd-vhosts.conf ,然后添加:
<VirtualHost 127.0.0.10:80> ServerAdmin [email protected] DocumentRoot "e:/demo" ServerName naruto.com ServerAlias www.naruto.com ErrorLog "logs/naruto.com-error.log" CustomLog "logs/naruto.com-access.log" common <Directory "e:/demo"> Options Indexes #不存在默认页面时,显示目录 AllowOverride None #不使用.htaccess,提高性能 Order deny,allow #顺序是先deny,然后allow Require all granted </Directory> </VirtualHost>