当前位置: 主页 » 网站开发 » apache 多站点配置

apache 多站点配置

2023年3月30日 15:58

apache 多站点配置

修改 conf/httpd.conf,添加如下配置信息,请根据情况自行修改

NameVirtualHost 127.0.0.1 <VirtualHost 127.0.0.1> DocumentRoot "D:/Inetpub/www/maidou/" ServerName www.maidou.info <Directory "D:/Inetpub/www/maidou/"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> # 多台可以再添加 <VirtualHost 127.0.0.1> DocumentRoot "D:/Inetpub/www/other/" ServerName www.other.com <Directory "D:/Inetpub/www/other/"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>

这里需要注意的是

Order allow,deny

这里的 deny 前不要加空格,由于编程习惯,我习惯于在逗号后添加空格,结果造成了重启 apache 不成功,呵呵

修改完这里,还要记得修改 “C:\Windows\System32\drivers\etc\hosts” 文件,添加

127.0.0.1 www.maidou.info 127.0.0.1 www.other.com

然后,重启 apache 就好了。修改完 hosts 文件后,Firefox好像需要重新启动一下才行。