一:预置条件
1:PHP环境部署完成
2:以Xampp集成环境为例
二:步骤
1:找到\apache\conf目录下的httpd.conf文件
去掉LoadModule vhost_alias_module modules/mod_vhost_alias.so之前的分号(或者#);
把以下两个地方修改为代码对应的路径
DocumentRoot "D:/test"
<Directory "D:/test">
2:找到\apache\conf\extra目录下的httpd-vhosts.conf文件,在文件末尾添加如下代码
order deny,allow 改为order allow,deny
<VirtualHost *:80>
ServerName portal.com (注:红色标注为你要访问时输入的地址)
ServerAlias portal.com *.portal.com
DocumentRoot "D:/portal/C20/portal/public" (注:项目路径)
ServerPath /portal
<Directory "D:/portal/C20/portal/public"> (注:项目路径)
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName cms.com
ServerAlias cms.com *.cms.com
DocumentRoot "D:/portal/C20/cms/public"
ServerPath /cms
<Directory "D:/portal/C20/cms/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
3:找到C:\Windows\System32\drivers\etc\目录下的hosts文件,在文件末尾添加如下代码
127.0.0.1 portal.com
127.0.0.1 *.portal.com
127.0.0.1 cms.com
127.0.0.1 *.cms.com
4:设置代理服务
IE浏览器-工具-Internet选项-连接-局域网设置-高级-输入portal.com;*.portal.com;cms.com;*.cms.com中间用逗号分隔
5:重启Apache服务