本文主要是介绍linux apache2 tomcat7 mod_jk 整合,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、安装的源文件httpd-2.4.12.tar.gz
apache-tomcat-7.0.61.tar.gz
tomcat-connectors-1.2.37-src.tar.gz
2、安装过程
首先
apache安装到 /usr/local/apache 目录下
tomcat 安装到 /usr/local/tomcat 目录下
其次,安装tomcat-connectors,过程如下:
# tar zxvf tomcat-connectors-1.2.37-src.tar.gz
# cd tomcat-connectors-1.2.37-src.tar.gz/native
# ./configure --with-apxs=/usr/local/apache/bin/apxs
# make
# cp ./apache-2.0/mod_jk.so /usr/local/apache/modules/
3、配置apache,过程如下:
在/usr/local/apache/conf/下面建立两个配置文件mod_jk.conf和workers.properties
# vi mod_jk.conf 添加以下内容:
# 指出mod_jk模块工作所需要的工作文件workers.properties的位置
JkWorkersFile /usr/local/apache/conf/workers.properties
# Where to put jk logs
JkLogFile /usr/local/apache/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"
# 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理
JkMount /servlet/* worker1
JkMount /*.jsp worker1
JkMount /* worker1 -- 外加
# vi workers.properties
添加以下内容:
# Defining a worker named worker1 and of type ajp13
worker.list=worker1
# Set properties for worker1
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
4、配置httpd.conf,作以下修改:
修改DocumentRoot,指向tomcat存放项目的目录
DocumentRoot "/usr/local/tomcat/webapps/ROOT"
<Directory "/usr/local/tomcat/webapps/ROOT">
Options Includes FollowSymLinks
AllowOverride None
Require all granted
Allow from all
</Directory>
增加关于加载mod_jk的语句:
LoadModule jk_module modules/mod_jk.so
Include /usr/local/apache/conf/mod_jk.conf
取消 LoadModule rewrite_modulemodules/mod_rewrite.so前的注释
RewriteEngineon
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="/usr/local/tomcat/webapps/ROOT" debug="0" reloadable="true" crossContext="true"/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
还有:
<Engine name="Catalina"defaultHost="localhost" jvmRoute="controller">
解开tomcat中对于8009端口的枷锁
<Connectorport="8009" protocol="AJP/1.3"redirectPort="8443" />
notice the authority of the file mod_jk.so
这篇关于linux apache2 tomcat7 mod_jk 整合的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!