Linux系统下Apache与Tomcat整合的办法[网络技术]
本文“Linux系统下Apache与Tomcat整合的办法[网络技术]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
1、预备,下载需求的文件.这里假定你已经精确安装配置好了JDK.
到Apache官方网站下载所需求的文件:httpd-2.2.0.tar.gz
apache-tomcat-5.5.12.tar.gz
jakarta-tomcat-connectors-1.2.15-src.tar.gz
此中httpd和jakarta-tomcat-connectors为源码包,apache-tomcat为二进制包.
2、安装Apache.# tar xzvf httpd-2.2.0.tar.gz
# cd httpd-2.2.0
# ./configure --prefix=/usr/local/apache2 --enable-so
# make
# make install
3、安装Tomcat.# cp apache-tomcat-5.5.12.tar.gz /usr/local/
# cd /usr/local
# tar xzvf apache-tomcat-5.5.12.tar.gz
# ln -s apache-tomcat-5.5.12 tomcat
4、编译生成mod_jk.# tar xzvf jakarta-tomcat-connectors-1.2.15-src.tar.gz
# cd jakarta-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.
# vi mod_jk.conf
增添以下内容:
# 指出mod_jk模块工作所需求的工作文件workers.properties的位置
JkWorkersFile /usr/local/apache2/conf/workers.properties
# Where to put jk logs
JkLogFile /usr/local/apache2/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 worker1JkMount *.action Worker1JkMount *.do 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
再配置httpd.conf,作以下改正:
将Listen 80 改正成 Listen 127.0.0.1:80
将ServerName 改正成 ServerName LocalHost:80
在DirectoryIndex中增添 index.jsp
我的网页放在/var/wwwroot下,所以要改正DocumentRoot
DocumentRoot "/var/wwwroot"
Options Includes FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
XBitHack on
Order deny,allow
Deny from all
增添关于加载mod_jk的语句:LoadModule jk_module modules/mod_jk.so
Include /usr/local/apache2/conf/mod_jk.conf
最后编辑Tomcat的配置文件server.xml,在HOST段中加入:
<Context path="" docBase="/var/wwwroot" debug="0" reloadable="true" crossContext="true"/>
在/var/wwwroot下成立一个index.jsp:
2 + 2 =
启动Apache和Tomcat,用浏览器拜候http://localhost/,应当可以看到精确的页面了.
以上是“Linux系统下Apache与Tomcat整合的办法[网络技术]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |