2016-07-27 97 views
0

我有我的apache配置有2個網站設置。我在我的apache2.conf以下Apache2上的多個網站

Include /opt/bitnami/apps/www.website1.com/conf/app.conf 
Include /opt/bitnami/apps/www.website2.com/conf/app.conf 

這裏有2個網站的app.conf

WEBSITE1

<VirtualHost *> 
DocumentRoot /opt/bitnami/apps/www.website1.com/htdocs 
ServerName www.website1.com:80 
ServerAlias website1.com 
ErrorLog /opt/bitnami/apps/www.website1.com/log/error.log 
CustomLog /opt/bitnami/apps/www.website1.com/log/access.log common 

<Directory "/opt/bitnami/apps/www.website1.com/htdocs"> 
    Options Indexes MultiViews 
    AllowOverride All 
    Order allow,deny 
    Allow from all 
</Directory> 
</VirtualHost> 

<VirtualHost *> 
DocumentRoot /opt/bitnami/apps/www.website1.com/htdocs 
ServerName website1.uat.com:80 
ServerAlias website1.uat.com 
ErrorLog /opt/bitnami/apps/www.website1.com/log/error.log 
CustomLog /opt/bitnami/apps/www.website1.com/log/access.log common 

<Directory "/opt/bitnami/apps/www.website1.com/htdocs"> 
    Options Indexes MultiViews 
    AllowOverride All 
    Order allow,deny 
    Allow from all 
</Directory> 

網站2

<VirtualHost *> 
DocumentRoot /opt/bitnami/apps/www.website2.com/htdocs 
ServerName www.website2.com:80 
ServerAlias www.website2.com 
ErrorLog /opt/bitnami/apps/www.website2.com/log/error.log 
CustomLog /opt/bitnami/apps/www.website2.com/log/access.log common 

<Directory "/opt/bitnami/apps/www.website2.com/htdocs"> 
    Options Indexes MultiViews 
    AllowOverride None 
    Order allow,deny 
    Allow from all 
</Directory> 
</VirtualHost> 


<VirtualHost *> 
DocumentRoot /opt/bitnami/apps/www.website2.com/htdocs 
ServerName website2.com:80 
ServerAlias website2.com 
ErrorLog /opt/bitnami/apps/www.website2.com/log/error.log 
CustomLog /opt/bitnami/apps/www.website2.com/log/access.log common 

<Directory "/opt/bitnami/apps/www.website2.com/htdocs"> 
    Options Indexes MultiViews 
    AllowOverride None 
    Order allow,deny 
    Allow from all 
</Directory> 

進出口檢驗這些地方,所以我有以下

xx.xxx.xx.xxx www.website1.com 
xx.xxx.xx.xxx www.website2.com 

我的主機設置,當我去www.website2.com,Apache2的頁面彈出 當我去www.website1.com,Apache2的頁面彈出up

當我去www.website2.com/htdocs,我看到了正確的網站,它的工作原理。當我訪問www.website1.com/htdocs時,我看到了網站2。我不明白爲什麼我在這裏看到網站2。

回答

1

我的第一個猜想是,你應該刪除該端口:從服務器名80,改變

<VirtualHost *> 

<VirtualHost *:80> 

像這樣:

<VirtualHost *:80> 
DocumentRoot /opt/bitnami/apps/www.website1.com/htdocs 
ServerName www.website1.com 
... 
-1

由於prerik說使用「VirtualHost *:80」

另外,如果它是Apache HTTPD 2.2.x,當幾個虛擬主機使用相同的ip:port方案時,它需要在配置中定義爲「一次」的「NamedVirtualHosts *:80」,如果您不添加所有請求將會在第一個定義的虛擬主機中登陸。