简体   繁体   English

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

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

I'm a new technical. 我是一个新技术人员。 My problem is, I have the web application that running on tomcat7. 我的问题是,我有在tomcat7上运行的Web应用程序。 now i want to install and configure mod_jk on windows server to connect apache and tomcat. 现在我想在Windows服务器上安装和配置mod_jk以连接apache和tomcat。

Please tell me, how to do that? 请告诉我,怎么做?

Thanks 谢谢

First of all you must download the correct mod_jk connector binaries depending on your apache httpd version from here: 首先,你必须从这里下载正确的mod_jk连接器二进制文件,具体取决于你的apache httpd版本:

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 modules文件夹中,通常是[APACHE_HOME]/modules

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文件,通常位于apache conf目录或其中的任何其他目录(conf.d,extra等)。

Usually workers.properties file 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.host and worker.worker1.port have correct values to reach your tomcat's ajp connector. 您必须检查worker.worker1.hostworker.worker1.port是否具有正确的值才能到达tomcat的ajp连接器。 8009 port is the commonly used, but better check that in your tomcat's server.xml and set the correct one in workers.properties. 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. 完成此操作后,您可以尝试重新启动Apache httpd以查看已完成的所有操作是否正确。 If apache starts correctly, now you can start planning how you would redirect matching requests from httpd to tomcat. 如果apache正确启动,现在您可以开始计划如何将匹配请求从httpd重定向到tomcat。 The easiest way is to redirect every request which matches the context path of your Tomcat webapp. 最简单的方法是重定向与Tomcat webapp的上下文路径匹配的每个请求。

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 worker1 must match the name you gave to the worker in workers.properties file. 请注意, worker1必须与您在workers.properties文件中为worker提供的名称相匹配。

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://本地主机/应用上下文/

And if you reach your Tomcat webapp, everything is done. 如果您使用Tomcat webapp,一切都已完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM