本地使用apache设置绑定多个域名

  1. Apache开启了使用虚拟主机的功能;

    打开Apache安装目录下conf/httpd.conf文件,找到

    #LoadModule vhost_alias_module modules/mod_vhost_alias.so

    把注释去掉,(删除#)

  2.  修改Apache安装目录下/conf/extra/httpd-vhosts.conf文件

    <VirtualHost *:80>
    ServerAdmin 127.0.0.1
    DocumentRoot "F:/phpweb/WWW/srcrm1.1"
    ServerName 127.0.0.1
    ServerAlias 127.0.0.1
    <Directory F:phpwebWWWsrcrm1.1>
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Allow from all
    DirectoryIndex index.php index.html
    </Directory>
    </VirtualHost>

    <VirtualHost *:80>
    ServerAdmin localhost
    DocumentRoot "F:/phpweb/WWW/newcrm/public"
    ServerName localhost
    ServerAlias localhost
    <Directory F:phpwebWWW ewcrmpublic>
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Allow from all
    DirectoryIndex index.php index.html
    </Directory>
    </VirtualHost>

  3. 修改c盘windows->system32->driver->etc->hosts文件(可忽略)

    (C:WindowsSystem32driversetc)

    添加:   ServerName  域名解析,指向本机

        127.0.0.1  ServerName1

       127.0.0.1  ServerName2

    。。。

    重启Apache,OK!

原文地址:https://www.cnblogs.com/qinglin/p/8705893.html