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
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:
If it is a 2.4, choose one of them depending if you prefer 64 or 32 bit version:
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:
And if you reach your Tomcat webapp, everything is done.