Apache2 + Tomcat5 配置多站点服务器

http://topic.csdn.net/u/20100125/17/f5c55a16-450b-4e4a-aa25-688111ad02ed.html

 

假如,现在有3个站点:www.ab26.com,w1.ab26.com,w2.ab26.com,均指向同一服务器(假如公网IP:11.22.333.444)。
下载mod_jk模块,并将其拷贝至Apache安装目录的modules目录下。

Apache配置:

1.修改配置文件httpd.conf,在文件尾加入下面两行:
Include conf/extra/mod_jk.conf
Include conf/extra/thosts.conf

2.在conf目录下新建文件夹extra,所有新建的配置文件都放在这里,以便管理。

3.在extra目录下新建文本文件thosts.conf,内容如下:

XML code
  
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> # www.ab26.com < VirtualHost 11.22.333.444:80 > ServerAdmin [email protected] ServerName ab26.com ServerAlias ab26.com www.ab26.com DocumentRoot "D:/websites/www.ab26.com/ROOT" Alias /mydl/ "D:/dl/" < Directory "D:/websites/www.ab26.com/ROOT" > Options FollowSymLinks AllowOverride None Order allow,deny Allow from all </ Directory > < Location ~"/WEB-INF/" > AllowOverride None deny from all </ Location > < Directory "D:/dl" > Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </ Directory > CustomLog "logs/www.ab26.com-access_2009.log" combined ErrorLog "logs/www.ab26.com-error_2009.log" JkLogFile "logs/www.ab26.com-jk-error_2009.log" JkLogLevel error DirectoryIndex default.htm index.htm default.jsp index.jsp JkMountFile conf/extra/www.ab26.com.properties </ VirtualHost > # w1.ab26.com < VirtualHost 11.22.333.444:80 > ServerAdmin [email protected] ServerName w1.ab26.com ServerAlias w1.ab26.com DocumentRoot "D:/websites/w1.ab26.com/ROOT" < Directory "D:/websites/w1.ab26.com/ROOT" > Options FollowSymLinks AllowOverride None Order allow,deny Allow from all </ Directory > < Location ~"/WEB-INF/" > AllowOverride None deny from all </ Location > CustomLog "logs/w1.ab26.com-access_2009.log" combined ErrorLog "logs/w1.ab26.com-error_2009.log" JkLogFile "logs/w1.ab26.com-jk-error_2009.log" JkLogLevel error DirectoryIndex default.htm index.htm default.jsp index.jsp JkMountFile conf/extra/w1.ab26.com.properties </ VirtualHost > # w2.ab26.com < VirtualHost 11.22.333.444:80 > ServerAdmin [email protected] ServerName w2.ab26.com ServerAlias w2.ab26.com DocumentRoot "D:/websites/w2.ab26.com/ROOT" < Directory "D:/websites/w2.ab26.com/ROOT" > Options FollowSymLinks AllowOverride None Order allow,deny Allow from all </ Directory > < Location ~"/WEB-INF/" > AllowOverride None deny from all </ Location > CustomLog "logs/w2.ab26.com-access_2009.log" combined ErrorLog "logs/w2.ab26.com-error_2009.log" JkLogFile "logs/w2.ab26.com-jk-error_2009.log" JkLogLevel error DirectoryIndex default.htm index.htm default.jsp index.jsp JkMountFile conf/extra/w2.ab26.com.properties </ VirtualHost >



4.在extra目录下新建文本文件mod_jk.conf,内容如下:
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/extra/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel error

5.在extra目录下新建文本文件workers.properties,内容如下:
workers.tomcat_home=C:\myServer\Tomcat-5.5
workers.java_home=C:\myServer\Java\jre6
worker.list=ajp13_a0,ajp13_a1,ajp13_a2
worker.ajp13_a0.port=8009
worker.ajp13_a0.host=127.0.0.1
worker.ajp13_a0.type=ajp13
worker.ajp13_a1.port=8109
worker.ajp13_a1.host=127.0.0.1
worker.ajp13_a1.type=ajp13
worker.ajp13_a2.port=8209
worker.ajp13_a2.host=127.0.0.1
worker.ajp13_a2.type=ajp13

6.在extra目录下新建文本文件www.ab26.com.properties,内容如下:
/*.jsp=ajp13_a0
/*.do=ajp13_a0
/fckeditor/*=ajp13_a0
!/*.gif=ajp13_a0
!/*.jpg=ajp13_a0
!/*.png=ajp13_a0
!/*.css=ajp13_a0
!/*.js=ajp13_a0
!/*.htm=ajp13_a0
!/*.html=ajp13_a0

7.在extra目录下新建文本文件w1.ab26.com.properties,内容如下:
/*.jsp=ajp13_a1
/*.do=ajp13_a1
/fckeditor/*=ajp13_a1
!/*.gif=ajp13_a1
!/*.jpg=ajp13_a1
!/*.png=ajp13_a1
!/*.css=ajp13_a1
!/*.js=ajp13_a1
!/*.htm=ajp13_a1
!/*.html=ajp13_a1

8.在extra目录下新建文本文件w2.ab26.com.properties,内容如下:
/*.jsp=ajp13_a2
/*.do=ajp13_a2
/fckeditor/*=ajp13_a2
!/*.gif=ajp13_a2
!/*.jpg=ajp13_a2
!/*.png=ajp13_a2
!/*.css=ajp13_a2
!/*.js=ajp13_a2
!/*.htm=ajp13_a2
!/*.html=ajp13_a2

Tomcat配置:

1.修改配置文件server.xml,找到『 <Connector port="8009" connectionTimeout="10000" .... protocol="AJP/1.3" />』,在其后添加以下内容:

XML code
  
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> < Connector port ="8109" connectionTimeout ="10000" enableLookups ="false" redirectPort ="8443" protocol ="AJP/1.3" /> < Connector port ="8209" connectionTimeout ="10000" enableLookups ="false" redirectPort ="8443" protocol ="AJP/1.3" />


说明:这一步的配置,我不知道是不是正确。

服务器上的网站现在可以正常浏览,但是也遇到点问题,我通过网站后台(使用了struts2框架)上传图片时,经常会出现图片上传失败的情况(也有上传成功的时候),我在本地测试时一切正常(本地使用Eclipse3+JDK6+Tomcat5开发环境)。不知道是网站程序有问题,还是网站服务器配置的问题。下面附上我上传图片的代码及Struts2的配置。

请高手帮忙指点一下,问题如能解决,不胜感激!

你可能感兴趣的:(tomcat,jsp,浏览器,fckeditor,配置管理)