如何在 Windows Server 上安装 mod_jk(Apache Tomcat 连接器)? [英] How to install mod_jk (Apache Tomcat Connectors) on Windows Server?

查看:44
本文介绍了如何在 Windows Server 上安装 mod_jk(Apache Tomcat 连接器)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名新技术.我的问题是,我有在 tomcat7 上运行的 Web 应用程序.现在我想在windows服务器上安装和配置mod_jk来连接apache和tomcat.

I'm a new technical. My problem is, I have the web application that running on tomcat7. now i want to install and configure mod_jk on windows server to connect apache and tomcat.

请告诉我,怎么做?

谢谢

推荐答案

首先,您必须从这里下载正确的 mod_jk 连接器二进制文件,具体取决于您的 apache httpd 版本:

First of all you must download the correct mod_jk connector binaries depending on your apache httpd version from here:

http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/

如果您的 apache 是 2.2 版本,请选择:

If your apache is a 2.2 version, choose this:

如果是 2.4,请根据您喜欢 64 位还是 32 位版本选择其中之一:

If it is a 2.4, choose one of them depending if you prefer 64 or 32 bit version:

下载并解压正确的一个.然后,从 zip 中提取 mod_jk.so 并将其放在您的 apache httpd 模块文件夹中,通常是 [APACHE_HOME]/modules

Download and unzip correct one. Then, extract mod_jk.so from the zip and place it in your apache httpd modules folder, typically [APACHE_HOME]/modules

完成后,您必须创建一个 workers.properties 文件,通常在 apache conf 目录或其中的任何其他目录(conf.d、extra 等)中.

Once done it, you must create a workers.properties file, typically in apache conf directory or any other inside it (conf.d, extra, etc).

通常workers.properties文件有以下内容:

worker.list=worker1,jkstatus

#Set properties for worker19 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009 
worker.worker1.ping_timeout=1000
worker.worker1.connect_timeout=10000
worker.worker1.prepost_timeout=10000
worker.worker1.socket_timeout=10
worker.worker1.connection_pool_timeout=60
worker.worker1.connection_pool_size=90
worker.worker1.retries=2
worker.worker1.reply_timeout=300000 

# status worker
worker.jkstatus.type=status

您必须检查 worker.worker1.hostworker.worker1.port 是否具有正确的值才能到达您的 tomcat 的 ajp 连接器.8009端口是常用的,但最好在你的tomcat的server.xml中检查,并在workers.properties中设置正确的.

You must check that worker.worker1.host and worker.worker1.port have correct values to reach your tomcat's ajp connector. 8009 port is the commonly used, but better check that in your tomcat's server.xml and set the correct one in workers.properties.

然后,在 httpd.conf 或任何其他外部 conf 文件中,添加以下内容:

Then, in httpd.conf or any other external conf file, add the following:

# Load mod_jk module
LoadModule jk_module modules/tomcat-connector/mod_jk.so

# Add the module (activate this lne for Apache 1.3)
# AddModule     mod_jk.c
# Where to find workers.properties
JkWorkersFile conf/extra/workers.properties # Check the path is correct to your workers.properties 
# Where to put jk shared memory
JkShmFile     logs/mod_jk.shm
# Where to put jk logs
JkLogFile     logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel    info 

完成此操作后,您可以尝试重新启动 Apache httpd 以查看已完成的所有操作是否正确.如果 apache 正确启动,现在您可以开始计划如何将匹配的请求从 httpd 重定向到 tomcat.最简单的方法是重定向与 Tomcat Web 应用程序的上下文路径匹配的每个请求.

Once done this, you could try restarting Apache httpd to see if everything already done is correct. If apache starts correctly, now you can start planning how you would redirect matching requests from httpd to tomcat. The easiest way is to redirect every request which matches the context path of your Tomcat webapp.

如果您的应用程序在 http://localhost:8080/app-context/ 中侦听,那么您可以简单地在 httpd.conf 或设置 load_module 语句的文件中添加它,就在 JKLogLevel 之后:

If your application listens in http://localhost:8080/app-context/ then you could simply add this in httpd.conf or the file where you set the load_module sentences, just after JKLogLevel:

JkMount  /app-context/* worker1

请注意,worker1 必须与您在 workers.properties 文件中为 worker 提供的名称相匹配.

Note here that worker1 must match the name you gave to the worker in workers.properties file.

现在,只需重新启动apache httpd,确保Tomcat正在运行,然后在浏览器中尝试下一个url:

Now, just restart apache httpd, make sure that Tomcat is running and then try in a browser next url:

http://localhost/app-context/

如果您访问 Tomcat Web 应用程序,一切都已完成.

And if you reach your Tomcat webapp, everything is done.

这篇关于如何在 Windows Server 上安装 mod_jk(Apache Tomcat 连接器)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆