首页>>帮助中心>>美国VPS如何整合httpd和tomcat

美国VPS如何整合httpd和tomcat

2024/8/16 265次

美国VPS如何整合httpd和tomcat



1、php+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

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

(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即可

购买使用一诺网络美国VPS,可以极大降低初创企业、中小企业以及个人开发者等用户群体的整体IT使用成本,无需亲自搭建基础设施、简化了运维和管理的日常工作量,使用户能够更专注于自身的业务发展和创新。美国VPS低至49/月,购买链接:https://www.enuoidc.com/vpszq.html?typeid=3

版权声明

    声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们996811936@qq.com进行处理。