windows 下apache多站点支持 [PHP]

来源:互联网 发布:鲁大师软件 编辑:程序博客网 时间:2024/06/05 02:18

转自:http://blog.chengyongju.com/?p=332

前一段时间只会借助windows的iis工具,添加多站点。但是xp的iis仅支持iis5.1 而iis5.1又不支持多站点。所以当离开windows7后就不能实现多站点了。进来闲来蛋疼,查阅资料研究一下通过修改apache配置文件,实现多站点。经历N次失败,个人觉得最重要的是 修改<Directory/></Directory> 里边的配置。还有<VirtualHost 127.0.0.1> 前边一定要加上NameVirtualHost 127.0.0.1 具体过程如下


第一步 修改apache配置文件 httpd.conf


<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
这里改成

<Directory />
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
否则会出现You don’t have permission to access / on this server.
然后添加如下代码
NameVirtualHost 127.0.0.1

# 第一个站点 me.ixis.cn
<VirtualHost 127.0.0.1>
DocumentRoot “d:/wamp/www/ixis/web/”
ServerName me.ixis.cn
DirectoryIndex index.php index.html index.htm
</virtualHost>

# 第二个站点 test.imakeupcc.com
<VirtualHost 127.0.0.1>
DocumentRoot “f:/root/imakeupcc/”
ServerName test.imakeupcc.com
DirectoryIndex index.php index.html index.htm
</virtualHost>



第二步 hosts文件加入如下代码

127.0.0.1 me.ixis.cn
127.0.0.1 test.imakeupcc.com



第三步 重启apache