1、在windows下本地域名解析设置: php
使用editPlus打开C:\WINDOWS\system32\drivers\etc\hosts文件进行编辑,以下:html
# Copyright (c) 1993-1999 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host 127.0.0.1 localhost 127.0.0.1 www.example.com
2、进行Apache服务器解析设置: apache
apache的配置文件在X:\php\Apache2\conf文件夹下,使用EditPlus打开httpd.conf文件进行编辑,以下: NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin localhost #无关紧要 DocumentRoot d:\Network #文件地址 ServerName localhost #写本身设定的虚拟域名或名称 # ErrorLog logs/dummy-host.example.com-error_log # CustomLog logs/dummy-host.example.com-access_log common <VirtualHost *:80> ServerAdmin www.example.com #无关紧要 DocumentRoot d:\Network ServerName www.example.com #写本身设定的虚拟域名或名称 # ErrorLog logs/dummy-host.example.com-error_log # CustomLog logs/dummy-host.example.com-access_log common </VirtualHost>
若是还要加虚拟地址,直接在上面一二步中的记录后面添加便可windows
若是hosts文件中有一条虚拟地址在httpd.conf文件中没有相对应的处理,貌似会被下一条虚拟地址覆盖,产生下一条虚拟地址的效果。服务器
3、检查配置http.conf中app
<Directory /> Options FollowSymLinks AllowOverride all Order deny,allow allow from all </Directory>
改成上述样式。ide
重启服务器。spa
或者将第三步直接添加入第二步中以下例子:code
<VirtualHost *:80> ServerName localhost DocumentRoot "D:\WEB" <Directory "D:\WEB"> Options FollowSymLinks IncludesNOEXEC Indexes DirectoryIndex index.html index.htm default.htm index.php default.php index.cgi default.cgi index.pl default.pl index.shtml AllowOverride All Allow from all </Directory> </VirtualHost>