如何整合httpd和tomcat

2015-10-14 21:09:32 10361

1php+httpd+mysql的安装请参考:https://www.landui.com/Help/Show-1000.html

2、tomcat安装参考:

https://www.landui.com/Help/Show-1206.html

3.下载mod_jk.so

(1)mod_jk.so依赖于httpd-devel   所有先安装:yum install httpd-devel

(2)下载mod_jk.so

#wget http://www.landui.com/dist/tomcat/tomcat-connectors/jk/ tomcat-connectors-1.2.41-src.tar.gz

#tar zxvf tomcat-connectors-1.2.41-src.tar.gz

#cd tomcat-connectors-1.2.41-src/native

#which apxs              #查apxs的路径

#./configure –with-paxs= /usr/sbin/apxs --with-java-home="java路径"     #java如果是yum安装一般在/usr/java/jdk中

#make

#cp apache-2.0/mod_jk.so /etc/httpd/modules

 mod_jk-1.2.23-apache-2.2.x-linux-ia64.so /etc/httpd/modules/mod_jk.so

4.创建文件:vi /etc/httpd/conf/workers.properties

workers.tomcat_home=/home/sdb5/tomcat7

# workers.java_home should point to your Java installation. Normally

# you should have a bin and lib directories beneath it.

workers.java_home=/home/sdb5/java/

# You should configure your environment slash... ps= on NT and / on UNIX

# and maybe something different elsewhere.

ps=/

worker.list=worker1

# Defining a worker named ajp13 and of type ajp13

# Note that the name and the type do not have to match.

worker.worker1.port=8009

worker.worker1.host=localhost

worker.worker1.type=ajp13

# Specifies the load balance factor when used with

# a load balancing worker.

# Note:

#  ----> lbfactor must be > 0

#  ----> Low lbfactor means less work done by the worker.

#worker.ajp13.lbfactor=1

# Specify the size of the open connection cache.

#worker.ajp13.cachesize

#------ DEFAULT LOAD BALANCER WORKER DEFINITION ----------------------

#---------------------------------------------------------------------

# The loadbalancer (type lb) workers perform wighted round-robin

# load balancing with sticky sessions.

# Note:

#  ----> If a worker dies, the load balancer will check its state

#        once in a while. Until then all work is redirected to peer

#        workers.

#worker.loadbalancer.type=lb

#worker.loadbalancer.balanced_workers=ajp12, ajp13

5.配置

(1)第一种方法

vi /etc/httpd/conf/http.conf

添加代码:

LoadModule jk_module /etc/httpd/modules/mod_jk.so

<IfModule jk_module>

       JkWorkersFile conf/workers.properties

       JkMountFile conf/uriworkermap.properties

       JkLogFile logs/mod_jk.log

       JkLogLevel warn

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

            JkMount /servlet/*  worker1

            JkMount /*.jsp worker1

</IfModule>

(2)第二种方法,这其实是为了保持httpd.conf文件的简洁把jk的模块单独设置。

       在/etc/httpd/conf/http.conf中输入:Include /etc/httpd/conf/mod_jk.conf

单独建立mod_jk的配置文件:mod_jk.conf:vi /etc/httpd/conf/mod_jk.conf

在其中输入:

# Load mod_jk module

LoadModule jk_module /etc/httpd/modules/mod_jk.so

# Where to find workers.properties

JkWorkersFile /etc/httpd/conf/workers.properties

# Where to put jk logs

JkLogFile logs/mod_jk.log

# Set the jk log level [debug/error/info]

JkLogLevel info

# Select the log format

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

# JkOptions indicate to send SSL KEY SIZE

JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format

JkRequestLogFormat "%w %V %T"

# Send servlet for context /examples to worker named ajp13

#JkMount /servlet/* worker1

# Send JSPs for context /examples to worker named ajp13

JkMount /servlet/*  worker1

JkMount /*.jsp worker1

JkMount /*.do worker1  #将所有servlet jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理

             # 注意JkMount后面的worker1即对应worker.properties文件中worker.list里的实例worker1的名称,也可以修改成其他名字如:ajp13

6.重启httpd即可

    

提交成功!非常感谢您的反馈,我们会继续努力做到更好!

这条文档是否有帮助解决问题?

非常抱歉未能帮助到您。为了给您提供更好的服务,我们很需要您进一步的反馈信息:

在文档使用中是否遇到以下问题: