方法/步骤
Apache配置虚拟主机方法在windows和linux有些差异,今天给大家演示如何在windows上配置Apache虚拟主机,此方法主要适用于独立的Apache环境。
1. 打开目录Apache的安装目录/conf/extra/, 找到 httpd-vhosts.conf 文件;
2. 添加一段代码来指定某一域名的网站,如图我配置虚拟域名是:
project.com,文件目录指向的是CI框架;
ServerAdmin webmaster@dummy-host.project.com
DocumentRoot "D:/AMP/Apache/htdocs/ci"
ServerName project.com
ErrorLog "logs/project.com-error.log"
CustomLog "logs/project.com-access.log" common
3. 打开 httpd.conf 文件, 添加如下代码:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
如果已存在,将Include前面的#去掉;
4. 重启 Apache 服务,打开虚拟域名之后,结果如图所示:
ServerName www.test1.com
DocumentRoot /www/test1/
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow From All
ServerName www.test1.com
DocumentRoot /www/test2/
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow From All
ServerName www.test1.com
DocumentRoot /www/test3/
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow From All
Apache中怎样设置虚拟主机?