linux下apache和tomcat的整合

1.首先到apache的官方网站下载软件包

httpd-2.2.0.tar.gz

apache-tomcat-5.5.12.tar.gz

jakarta-tomcat-connectors-1.2.15-src.tar.gz

2、安装Apache。

#tarxzvfhttpd-2.2.0.tar.gz

#cdhttpd-2.2.0

#./configure--prefix=/usr/local/apache2--enable-so

#make

#makeinstall

3、安装Tomcat。

#cpapache-tomcat-5.5.12.tar.gz/usr/local/

#cd/usr/local

#tarxzvfapache-tomcat-5.5.12.tar.gz

#ln-sapache-tomcat-5.5.12tomcat

4、编译生成mod_jk。

#tarxzvfjakarta-tomcat-connectors-1.2.15-src.tar.gz

#cdjakarta-tomcat-connectors-1.2.15-src/jk/native

#./configure--with-apxs=/usr/local/apache2/bin/apxs

#make

#cp./apache-2.0/mod_jk.so/usr/local/apache2/modules/

5、配置。

在/usr/local/apache2/conf/下面建立两个配置文件mod_jk.conf和workers.properties。

#vimod_jk.conf

添加以下内容:

#指出mod_jk模块工作所需要的工作文件workers.properties的位置

JkWorkersFile/usr/local/apache2/conf/workers.properties

#Wheretoputjklogs

JkLogFile/usr/local/apache2/logs/mod_jk.log

#Setthejkloglevel[debug/error/info]

JkLogLevelinfo

#Selectthelogformat

JkLogStampFormat"[%a%b%d%H:%M:%S%Y]"

#JkOptionsindicatetosendSSLKEYSIZE,

JkOptions+ForwardKeySize+ForwardURICompat-ForwardDirectories

#JkRequestLogFormatsettherequestformat

JkRequestLogFormat"%w%V%T"

#将所有servlet和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理

JkMount/servlet/*worker1

JkMount/*.jspworker1

#viworkers.properties

添加以下内容:

#Definingaworkernamedworker1andoftypeajp13

worker.list=worker1

#Setpropertiesforworker1

worker.worker1.type=ajp13

worker.worker1.host=localhost

worker.worker1.port=8009

worker.worker1.lbfactor=50

worker.worker1.cachesize=10

worker.worker1.cache_timeout=600

worker.worker1.socket_keepalive=1

worker.worker1.socket_timeout=300

再配置httpd.conf,作以下修改:

将Listen80修改为Listen127.0.0.1:80

将ServerName修改为ServerNameLocalHost:80

增加关于加载mod_jk的语句:

LoadModulejk_modulemodules/mod_jk.so

Include/usr/local/apache2/conf/mod_jk.conf

编辑Tomcat的配置文件server.xml,在HOST段中加入:

<Contextpath=""docBase="/usr/local/apache/htdocs"debug="0"reloadable="true"crossContext="true"/>

启动Apache和Tomcat,用浏览器访问http://localhost/,如果在浏览器中出现Itworks!则证明配置正确

相关推荐