如何在 Windows Server 上安装 mod_jk(Apache Tomcat 连接器)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41011820/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:44:40  来源:igfitidea点击:

How to install mod_jk (Apache Tomcat Connectors) on Windows Server?

windowsapachetomcattomcat7mod-jk

提问by Rith Udom

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.

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

Please tell me, how to do that?

请告诉我,如何做到这一点?

Thanks

谢谢

回答by jlumietu

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

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

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

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

If your apache is a 2.2 version, choose this:

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

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

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

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

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

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

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

Usually workers.propertiesfile has following content:

通常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

You must check that worker.worker1.hostand worker.worker1.porthave 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.

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

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

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

# 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 

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.

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

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:

如果您的应用程序在http://localhost:8080/app-context/ 中侦听,那么您只需将其添加到 httpd.conf 或设置 load_module 语句的文件中,就在 JKLogLevel 之后:

JkMount  /app-context/* worker1

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

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

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

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

http://localhost/app-context/

http://localhost/app-context/

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

如果你到达你的 Tomcat webapp,一切都完成了。