配置 Apache 的虚拟主机

时间:2024-01-20 08:32:21

1.在host配置比如: 找到记事本以管理员的身份打开,然后文件->打开  C:\Windows\System32\drivers\etc    下面的hosts文件

127.0.0.1 www.a.com
127.0.0.1 www.b.com
127.0.0.1 www.c.com
127.0.0.1 mp.sunyeart.com

2.配置httpd.conf

# 多域名虚拟主机配置 #
# manage #
<virtualhost *:80> #域名 ServerName www.a.com #网站目录
DocumentRoot D:\xampp\htdocs\manage\app\public #这里配置欢迎首页面
DirectoryIndex index.html index.htm index.php <Directory "D:\xampp\htdocs\manage\app\public">
Options FollowSymLinks ExecCGI #不允许别人修改我们的页面 AllowOverride All
#设置访问权限
Order allow,deny
Allow from all
Require all granted
</Directory>
</virtualhost> # hdjweixin #
<virtualhost *:80> ServerName mp.sunyeart.com
DocumentRoot D:\xampp\htdocs\mp\app\public
</virtualhost> # merchant #
<virtualhost *:80> ServerName www.b.com DocumentRoot D:\xampp\htdocs\merchant\app\public </virtualhost> # property #
<virtualhost *:80> ServerName www.c.com DocumentRoot D:\xampp\htdocs\property\app\public </virtualhost>