apache 多域名配置

时间:2023-03-09 16:05:31
apache 多域名配置

一直不明白apache多域名配置的问题,所以只能用不同的端口来配置,现在终于搞懂了一点

首先,开启apache的vhost模块

找到配置文件httpd.conf中的下面两行

#LoadModule vhost_alias_module modules/mod_vhost_alias.so

...

#Include conf/extra/httpd-vhosts.conf

去掉前面的注释#

打开httpd-vhosts.conf文件,添加内容 (直接复制前面的VirtualHost标签,然后修改对应的内容就可以)

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.sun.cm //这个是自己填的无所谓
DocumentRoot E:\wamp\www //所要配置的域名访问的根目录
ServerName crm.a.cc //域名的名称,我自己配的是“a”
ServerAlias crm.a.cc
#AccessFileName web.config
<Directory "E:\wamp\www">
AllowOverride FileInfo
Options Indexes Includes FollowSymLinks
Order allow,deny
Allow from all
DirectoryIndex index.html index.php
</Directory>
</VirtualHost>

最后,做一下重定向

打开C:\Windows\System32\drivers\etc\hosts文件

添加一行

192.168.1.102       a

ok,配置结束

现在可以打开浏览器测试一下,http://a/