首页 > 代码库 > httpd与tomcat基于mod_jk整合
httpd与tomcat基于mod_jk整合
搞定在前面述,
httpd与tomcat整合方式 当前已知的有 ajp_proxy,mod_jk.so
jk connecteor连接器下载地址
http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/
具体搞定策略步骤
1,安装httpd,基于yum安装
yum install httpd httpd-devel(安装成功后,会有/usr/sbin/apxs服务,mod_jk的编译依赖于apxs)
2,部署tomcat,基于官网二进制包安装,(很很简单)
3,开始基于mod_jk方式整合httpd与tomcat
下载tomcat-connector
wget http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.32-src.tar.gz
mv tomcat-connectors-1.2.32 /opt/mod_jkcd /opt/mod_jk/native./configure--with-apxs=/usr/sbin/apxs --with-java-home=/opt/javaMakeMake install
复制mod_jk.so
cp/opt/mod_jk/native/apache-2.0/mod_jk.so /usr/lib64/httpd/modules/
修改httpd配置
创建workers.properties
vim /etc/httpd/conf/workers.properties 添加以下内容:
# Defining a workernamed worker1 and of type ajp13worker.list=worker1# Set properties forworker1worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009worker.worker1.lbfactor=50 worker.worker1.cachesize=10 worker.worker1.cache_timeout=600 worker.worker1.socket_keepalive=1 worker.worker1.socket_timeout=300
创建 mod_jk.conf
vim /etc/httpd/conf/mod_jk.conf 添加以下内容:
JkWorkersFile /etc/httpd/conf/workers.properties# Where to put jk logsJkLogFile/etc/httpd/logs/mod_jk.log# Set the jk log level[debug/error/info]JkLogLevel info# Select the log formatJkLogStampFormat"[%a %b %d %H:%M:%S %Y]"# JkOptions indicate tosend SSL KEY SIZE,JkOptions +ForwardKeySize +ForwardURICompat-ForwardDirectories# JkRequestLogFormat setthe request formatJkRequestLogFormat"%w %V %T"# 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理JkMount /servlet/* worker1JkMount /*.jsp worker1
修改httpd.conf
vim httpd.conf 修改以下内容
ServerName修改为:ServerName 10.11.18.45:80DirectoryIndex 行添加 index.jsp index.htm
添加以下内容,其中”/var/wwwroot”是你要发布的Web项目所在的父目录
DocumentRoot"/var/wwwroot"<Directory"/var/wwwroot"> Options Includes FollowSymLinks AllowOverride None Order deny,allow Allow from all XBitHack on</Directory><Directory"/var/wwwroot/WEB-INF"> Order deny,allow Deny from all</Directory>
以下内容:添加
LoadModule jk_module/usr/lib64/httpd/modules/mod_jk.soInclude/etc/httpd/conf/mod_jk.conf
修改tomcat的配置
vim $TOMCAT_HOME/conf/server.xml
将 <Server …>部分 修改为<Hostname="localhost" appBase="/var/wwwroot" unpackWARs="true"autoDeploy="true">
restart httpd 和 tomcat
/etc/init.d/httpd restart$TOMCAT_HOME/bin/shutdown.sh$TOMCAT_HOME/bin/startup.sh
测试
在/var/wwwroot 目录下新建目录myproject,m yproject下新建index.jsp
<%@ page language="java" import="java.util.*"pageEncoding="ISO-8859-1"%><%String path = request.getContextPath();String basePath =request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <basehref="http://www.mamicode.com/"> <title>My JSP ‘index.jsp‘ startingpage</title> <meta http-equiv="pragma"content="no-cache"> <metahttp-equiv="cache-control" content="no-cache"> <meta http-equiv="expires"content="0"> <metahttp-equiv="keywords" content="keyword1,keyword2,keyword3"> <metahttp-equiv="description" content="This is my page"> <!-- <link rel="stylesheet"type="text/css" href="http://www.mamicode.com/styles.css"> --> </head> <body> Hello, I am mango_song ,this is my JSPpage. <br> </body></html>
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。