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>