apache配置多域名对应多项目、多端口多项目

打开conf里面的httpd.conf文件,把

#Include conf/extra/httpd-vhosts.conf

前面的注释符号“#”去掉。

1、多域名多项目:

打开conf/extra里面的httpd-vhosts.conf文件,参考以下代码:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin [email protected]
#下面这里配置项目路径
    DocumentRoot "D:/wamp/apps/a" 
#这里配置项目的访问域名,这个域名要在C:\Windows\System32\drivers\etc里面的hosts文件中声明:
#127.0.0.1  www.a.com
#127.0.0.1  www.b.com
    ServerName www.a.com
    ServerAlias www.a.com
    ErrorLog "logs/a-error.log"
    CustomLog "logs/a-access.log" common
    
    <Directory "D:/wamp/apps/a">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "D:/wamp/apps/b"
    ServerName www.lhc.com
    ServerAlias www.lhc.com
    ErrorLog "logs/b-error.log"
    CustomLog "logs/b-access.log" common
    
    <Directory "D:/wamp/apps/b">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>


2、多端口多项目:

这里配置完成之后,用端口访问项目:localhost:81 或 localhost:82

打开conf/extra里面的httpd-vhosts.conf文件,参考以下代码:

Listen 81
NameVirtualHost *:81
<VirtualHost *:81>
    ServerAdmin [email protected]
    DocumentRoot "D:/wamp/apps/a"
    ErrorLog "logs/81-error.log"
    CustomLog "logs/81-access.log" common
    
    <Directory "D:/wamp/apps/a">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>
Listen 82
NameVirtualHost *:82
<VirtualHost *:82>
    ServerAdmin [email protected]
    DocumentRoot "D:/wamp/apps/b"
    ErrorLog "logs/82-error.log"
    CustomLog "logs/82-access.log" common
    
    <Directory "D:/wamp/apps/b">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>



你可能感兴趣的:(apache配置多域名对应多项目、多端口多项目)