Apache應用中多個站點的解決方法

在整合Apache應用中,有兩個站點,server104.example.com和www104.example.com發現第二站點被第一個站點給覆蓋,又不能改變訪問的80端口號,解決方法設置總結如下:

主要設置httpd.conf

1DirectoryIndex的設置

如果多個虛擬站點中包含多種文件格式和文件名的首頁文件,必須在這裏全部出現

2、多個站點的定義如下

#NameVirtualHost *:80

# VirtualHost example:

# Almost any Apache directive may go into aVirtualHost container.

# The first VirtualHost section is used forrequests without a known

# server name.

NameVirtualHost 192.168.0.104:80

<VirtualHost 192.168.0.104:80>

   ServerAdmin [email protected]

    DocumentRoot  /var/www/html/server104

    ServerNameserver104.example.com

    DirectoryIndex   example.html

    ErrorLoglogs/ronglian.com-error_log

    CustomLoglogs/ronglian.com-access_log common

</VirtualHost>

<VirtualHost 192.168.0.104:80>

   ServerAdmin [email protected]

    DocumentRoot  /var/www/html/www104

    ServerName   www104.example.com

     DirectoryIndex   virtual.html

    ErrorLoglogs/chinaface.net-error_log

    CustomLoglogs/chinaface.net-access_log common

</VirtualHost>

①在這裏,NameVirtualHost的字段不能省略,否則起apache時報錯:VirtualHost 192.168.0.104.80 overlaps with VirtualHost192.168.0.104:80, the first has precedence, perhaps you need a NameVirtualHostdirective——雖然apache能起,同錯誤描述一樣,第二個站點的定義被第一個站點的定義所覆蓋,即訪問第二個站點指向的其實是第一個。

NameVirtualHost字段的端口號不能忽略,否則起apache時報錯:VirtualHost 192.168.0.104:80 -- mixing * ports and non-* ports witha NameVirtualHost address is not supported, proceeding with undefined results

[Sun Jul 09 16:59:37 2014] [error]VirtualHost 192.16.0.104.*:80 -- mixing * ports and non-* ports with aNameVirtualHost address is not supported, proceeding with undefined results——apache不能起作用.



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章