如何在Windows Server上安装mod_jk(Apache Tomcat连接器)? [英] How to install mod_jk (Apache Tomcat Connectors) on Windows Server?
问题描述
我是新手.我的问题是,我有在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.
请告诉我,该怎么做?
谢谢
推荐答案
首先,必须根据您的apache httpd
版本从此处下载正确的mod_jk连接器二进制文件:
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:
- http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/tomcat-connectors-1.2.40-windows-i386-httpd-2.4.x.zip
- http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/tomcat-connectors-1.2.40-windows-x86_64-httpd-2.4.x.zip
下载并解压缩正确的一个.然后,从zip中解压缩mod_jk.so并将其放置在您的apache httpd modules文件夹中,通常为
[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
文件具有以下内容:Usually
workers.properties
file has following content: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.host
和worker.worker1.port
的值是否正确,才能连接到tomcat的ajp连接器.通常使用8009端口,但最好在tomcat的server.xml中进行检查,并在worker.properties中设置正确的端口.You must check that
worker.worker1.host
andworker.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/,那么您只需在JKLogLevel之后将其简单地添加到httpd.conf或您设置load_module语句的文件中即可:
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
必须与您在worker.properties文件中为工作人员提供的名称匹配.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:
如果您访问了Tomcat Web应用程序,一切就完成了.
And if you reach your Tomcat webapp, everything is done.
这篇关于如何在Windows Server上安装mod_jk(Apache Tomcat连接器)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!