在整合Apache和Tomcat之后,發(fā)現(xiàn)該服務(wù)器的兩個(gè)網(wǎng)站一個(gè)是靜態(tài)的,一個(gè)是動(dòng)態(tài)jsp的,設(shè)置總結(jié)如下
主要設(shè)置httpd.conf
1、DirectoryIndex的設(shè)置
如果多個(gè)虛擬站點(diǎn)中包含多種文件格式和文件名的首頁文件,必須在這里全部出現(xiàn)
2、多個(gè)站點(diǎn)的定義如下
#NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
NameVirtualHost 220.231.32.*:80
<VirtualHost 220.231.32.*:80>
ServerAdmin liubin@sina.com
DocumentRoot /usr/local/tomcat/webapps/ronglian
ServerName www.ronglian.com
ErrorLog logs/ronglian.com-error_log
CustomLog logs/ronglian.com-access_log common
</VirtualHost>
<VirtualHost 220.231.32.*:80>
ServerAdmin wellboby@tom.com
DocumentRoot /usr/local/wwwroot/chinaface
ServerName www.chinaface.net
ErrorLog logs/chinaface.net-error_log
CustomLog logs/chinaface.net-access_log common
</VirtualHost>
!! 在這里,NameVirtualHost的字段不能省略,否則起apache時(shí)報(bào)錯(cuò):VirtualHost 220.231.32.*.80 overlaps with VirtualHost 220.231.32.*:80, the first has precedence, perhaps you need a NameVirtualHost directive——雖然apache能起,同錯(cuò)誤描述一樣,第二個(gè)站點(diǎn)的定義被第一個(gè)站點(diǎn)的定義所覆蓋,即訪問第二個(gè)站點(diǎn)指向的其實(shí)是第一個(gè)
!!
NameVirtualHost字段的端口號(hào)不能忽略,否則起apache時(shí)報(bào)錯(cuò):VirtualHost 220.231.32.*:80 --
mixing * ports and non-* ports with a NameVirtualHost address is not
supported, proceeding with undefined results
[Sun Jul 09 16:59:37
2006] [error] VirtualHost 220.231.32.*:80 -- mixing * ports and non-*
ports with a NameVirtualHost address is not supported, proceeding with
undefined results——apache不能起
!!如果VirtualHost 字段的端口號(hào)確實(shí),起apache時(shí)報(bào)錯(cuò):VirtualHost 220.231.32.28:0 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results——但apache可以啟動(dòng),訪問也正常