[项目背景]
因为项目需要,要构建以下系统
Platform: HP-UX ux14227 B.11.00 U 9000/800 (tb)
Http Server: Apache 2.0 (httpd 2.0.54)
Tomcat: Tomcat 4.1.18
Http-Tomcat connector: jk 1.2
Subversion: Subversion 1.2.0
Axis: 1.2
JDK: 1.4.2
gcc version: 3.3.2
之前以后成功的安装和配置了Apache、Tomcat、axis和Subversion,但是在整合Apache server 和Tomcat的时候,根据网上的例子怎么也无法成功。所以记录下自己的配置过程希望能给后来者一些帮助。
说明:需要Apache server + Tomcat的原因:
Tomcat只能支持Jsp + Servlet,即动态页面,不能支持静态页面;Apache很好的支持了静态页面,但是不支持Jsp+Servlet的动态页面,而且Apache支持SSL。这就是要把Apache和Tomcat整合在一起的原因。
[步骤]
1) 因为最新的Apache, tomcat connector 是jk, 所以因为使用适合mod_jk.so的安装范例(笔者在这里走了一些弯路)。主要参考文章:
http://oldblog.blogchina.com/article_65275.420876.html
http://www.johnturner.com/howto/apache2-tomcat4127-jk-rh9-howto.html
The first article is the practice of the second one. My article is the practice of the first one. So I will not repeat the steps if they are in these two articles.
2) Install JDK, set $JAVA_HOME
3) Install Apache httpd server
a. Download httpd-2.0.54
b. tar –xvf httpd-2.0.54.tar
c. ./configure --prefix=/home/pntest3/app/apache2 --enable-so --enable-dav
d. make
e. make install
f. cd conf
g. vi httpd.conf
h. Change 80 -> 9000
i. Uncommented ServerName, set ServerName localhost:9000
4) Install Subversion
a. Download subversion-1.2.0.tar.gz
b. Unzip it
c. ./configure --prefix=/home/pntest3/app/subversion --with-apxs=/home/pntest3/app/apache2/bin/apxs
d. make
e. make install
f. cd $SUBVERSION_HOME/bin
g. svnserve –version
h. svnadmin create /home/pntest3/app/subversion/data
i. add following into httpd.conf
<Location /svn/repository>
DAV svn
SVNPath /home/pntest3/app/subversion/data
</Location>
5) Install Tomcat
a. Download jakarta-tomcat-4.1.18.tar
b. Tar –xvf jakarta-tomcat-4.1.18.tar
c. Copy to the appropriate folder
d. Modify ./conf/server.xml
i. 8080 -> 9002
6) Deploy axis
a. cp -Rf /home/pntest3/install/axis-1_2/webapps/axis .
b. cd axis/WEB_INF/lib
c. cp /home/pntest3/install/axislib/xmlsec.jar .
d. cd $CATALINA_HOME/common/lib
e. cp $CATALINA_HOME/webapps/axis/WEB-INF/lib/* .
f. copy a class file to $AXIS_HOME/WEB-INF/classes
g. copy deploy.wsdd and undeploy.wsdd to $AXIS_HOME/WEB-INF
h. java -cp $WSDDCLASSPATH org.apache.axis.client.AdminClient -lhttp://localhost:9002/axis/services/AdminService deploy.wsdd
i. Test
7) Install connector – jk
a. Download jakarta-tomcat-connectors-current-src.tar
b. tar –xvf jakarta-tomcat-connectors-current-src.tar
c. cd $CONNECTOR_HOME/jk/native
d. ./buildconf.sh
e. ./configure --with-apxs=/home/pntest3/app/apache2/bin/apxs
f. make
g. make install
h. There will be error, but doesn’t matter mod_jk.so has been copied
8) Integration
a. cd $CATALANA_HOME/conf
b. vi server.xml
c. Search for 8005, add the following
<Listener className="org.apache.ajp.tomcat4.config.ApacheConfig"
modJk="/home/pntest3/app/apache2/modules/mod_jk.so" />
d. Add the following in host container
<Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" append="true" forwardAll="false" modJk="/home/pntest3/app/apache2/modules/mod_jk.so" workersConfig="/home/pntest3/app/jakarta-tomcat-4.1.18/conf/jk/workers.properties" />
e. Modify httpd.conf, add the following at the end of the file
Include /home/pntest3/app/jakarta-tomcat-4.1.18/conf/auto/mod_jk.conf
f. LoadModule jk_module modules/mod_jk.so
g. 8009 -> 9005 in server.xml and httpd.conf
h. Modify to the following
DocumentRoot "/home/pntest3/app/jakarta-tomcat-4.1.18/webapps/ROOT"
<Directory "/home/pntest3/app/jakarta-tomcat-4.1.18/webapps/ROOT">
DirectoryIndex index.html index.html.var index.jsp
i. Add workers.properties to $CATALINA_HOME/conf/jk, the content is the following
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
9) Test
a. Start tomcat, when there is /auto under /conf
b. Start apache