要想在单机上设置虚拟主机功能,需修改以下文件:
C:\WINNT\system32\drivers\etc\hosts
apache的配置文件 httpd.conf 和虚拟主机配置文件httpd-vhosts.conf
过程如下:
1.设置 hosts 文件,在里面添加如下:
127.0.0.1 localhost
# *********以下是本机服务器开发设置的虚拟主机设置
127.0.0.1 tmp.iamsese.cn
2. 设置 httpd.conf
# Virtual hosts -- 去除掉下面的#字符
Include conf/extra/httpd-vhosts.conf
3. 设置 httpd-vhosts.conf
#设置虚拟主机localhost 这个必须设置 --很多教程上没有说这点,导致很多问题
<VirtualHost *:80>
ServerName localhost
ServerAdmin vb2005xu@sese.cn
DocumentRoot D:\AppServ\www
ErrorLog logs/localhost-error_log.txt
</VirtualHost>
# 下面设置你的虚拟主机目录设置 -- 指定访问权限 和 虚拟目录
<Directory "D:/AppServ/devprj/www.iamsese.cn">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerName tmp.iamsese.cn
ServerAdmin vb2005xu@qq.com
DocumentRoot D:\AppServ\devprj\www.iamsese.cn
ErrorLog logs/tmp.iamsese.cn-error_log.txt
</VirtualHost>