三个步骤实现apache自定义域名访问,多域名访问,多站点访问:
1.本地添加域名
windows下,C:\WINDOWS\system32\drivers\etc\hosts文件内添加域名记录,类似于
127.0.0.1 pc.iseexn.com
2.httpd.conf中启用vhost
xampp默认是开启vhost的,如果下面的注释了,取消注释
Include "conf/extra/httpd-vhosts.conf"
3.在httpd-vhosts.conf中添加域名信息
3.1去掉 NameVirtualHost *:80 前面的注释
3.2添加目录访问权限,如:
<Directory D:\Project>
Order allow,deny
Allow from all
AllowOverride All
</Directory>
3.3添加域名信息,如:
3.3.1 localhost域名
<VirtualHost *:80>
DocumentRoot "C:/install_dir/xampp/htdocs"
ServerName localhost
</VirtualHost>
3.3.2 简单配置
<VirtualHost *:80>
DocumentRoot "D:\Project\Image_Center"
ServerName im.iseexn.com
</VirtualHost>
3.3.3 多一些配置
<VirtualHost *:80>
ServerAdmin admin@pc.iseexn.com
DocumentRoot "D:\Project\Product_Center"
ServerName pc.iseexn.com
ServerAlias www.pc.iseexn.com
ErrorLog "logs/pc.iseexn.com-error.log"
CustomLog "logs/pc.iseexn.com-access.log" combined
</VirtualHost>