一、在windows下本地域名解析设置:
使用editPlus打开C:\WINDOWS\system32\drivers\etc\hosts文件进行编辑,如下:
# 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
二、进行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>
如果还要加虚拟地址,直接在上面一二步中的记录后面添加即可
如果hosts文件中有一条虚拟地址在httpd.conf文件中没有相对应的处理,貌似会被下一条虚拟地址覆盖,产生下一条虚拟地址的效果。
三、检查配置http.conf中
<Directory />
Options FollowSymLinks
AllowOverride all
Order deny,allow
allow from all
</Directory>
改为上述样式。
重启服务器。
或者将第三步直接添加入第二步中如下例子:
<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>