Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. now i want to install and configure mod_jk on windows server to connect apache and tomcat.

Please tell me, how to do that?

Thanks

like image 440
Rith Udom Avatar asked Dec 07 '16 07:12

Rith Udom


People also ask

What is mod_jk connector?

The mod_jk connector is an Apache HTTPD module that allows HTTPD to communicate with Apache Tomcat instances over the AJP protocol. The module is used in conjunction with Tomcat's AJP Connector component.

What are the two types of connectors used in Tomcat?

There are two basic Connector types available in Tomcat - HTTP and AJP. Here's some information about how they differ from one another, and situations in which you might use them.

Where is mod_jk?

You should see a mod_jk.so file in the directory. Copy the mod_jk.so file into the apache modules directory. This should be located in the /usr/lib/apache2/modules or /etc/httpd/modules.

What is difference between mod_jk and mod_proxy?

Which connector: mod_jk or mod_proxy? mod_jk is mature, stable and extremely flexible. It is under active development by members of the Tomcat community. mod_proxy_ajp is distributed with Apache httpd 2.2 and later.


1 Answers

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/

If your apache is a 2.2 version, choose this:

  • http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/tomcat-connectors-1.2.40-windows-i386-httpd-2.2.x.zip

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

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

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

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

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.

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 

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.

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

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

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

http://localhost/app-context/

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

like image 143
jlumietu Avatar answered Oct 06 '22 01:10

jlumietu