{"id":9656,"date":"2014-03-03T18:42:04","date_gmt":"2014-03-03T23:42:04","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=9656"},"modified":"2014-03-15T08:51:47","modified_gmt":"2014-03-15T13:51:47","slug":"configure-mod_jk-for-apache-2-2-and-tomcat-7","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=9656","title":{"rendered":"Configure mod_jk for Apache 2.2 and Tomcat 7"},"content":{"rendered":"<div class='toc wptoc'>\n<h2>Contents<\/h2>\n<ol class='toc-odd level-1'>\n\t<li>\n\t\t<a href=\"#Environment\">Environment<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Prerequisites\">Prerequisites<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Download_mod_jk_Binary\">Download mod_jk Binary<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Configure_mod_jk_for_Apache\">Configure mod_jk for Apache<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Test\">Test<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#References\">References<\/a>\n\t<\/li>\n<\/ol>\n<\/ol>\n<\/div>\n<div class='wptoc-end'>&nbsp;<\/div>\n<span id=\"Environment\"><h2>Environment<\/h2><\/span>\n<pre lang=\"bash\">\r\n# cat \/etc\/redhat-release\r\nCentOS release 6.2 (Final)\r\n# uname -a\r\nLinux openidmbox.mytest.local 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU\/Linux\r\n# hostname\r\nopenidmbox.mytest.local\r\n<\/pre>\n<span id=\"Prerequisites\"><h2>Prerequisites<\/h2><\/span>\n<p>* Install Apache 2<\/p>\n<pre lang=\"bash\">\r\n# httpd -v\r\nServer version: Apache\/2.2.15 (Unix)\r\nServer built:   Dec  8 2011 18:10:49\r\n<\/pre>\n<p>* Install Tomcat<\/p>\n<pre lang=\"bash\">\r\n# cat RELEASE-NOTES |grep Version\r\n  The ASF licenses this file to You under the Apache License, Version 2.0\r\n                     Apache Tomcat Version 7.0.30\r\n<\/pre>\n<span id=\"Download_mod_jk_Binary\"><h2>Download mod_jk Binary<\/h2><\/span>\n<p>* Download <a href=\"http:\/\/archive.apache.org\/dist\/tomcat\/tomcat-connectors\/jk\/binaries\/linux\/jk-1.2.31\/x86_64\/mod_jk-1.2.31-httpd-2.2.x.so\">mod_jk-1.2.31-httpd-2.2.x.so<\/a> since our httpd version is 2.2.15<\/p>\n<pre lang=\"bash\">\r\ncd \/etc\/httpd\/modules\r\nwget http:\/\/archive.apache.org\/dist\/tomcat\/tomcat-connectors\/jk\/binaries\/linux\/jk-1.2.31\/x86_64\/mod_jk-1.2.31-httpd-2.2.x.so\r\nln -s mod_jk-1.2.31-httpd-2.2.x.so mod_jk.so\r\n<\/pre>\n<p>* Check <a href=\"http:\/\/archive.apache.org\/dist\/tomcat\/tomcat-connectors\/jk\/binaries\/linux\/\">here<\/a> for other mod_jk binaries.<\/p>\n<span id=\"Configure_mod_jk_for_Apache\"><h2>Configure mod_jk for Apache<\/h2><\/span>\n<p>* Create <em>\/etc\/httpd\/conf\/workers.properties<\/em> file:<\/p>\n<pre lang=\"bash\">\r\n# Define 1 real worker using ajp13\r\nworker.list=worker1\r\n# Set properties for worker1 (ajp13)\r\nworker.worker1.type=ajp13\r\nworker.worker1.host=localhost\r\nworker.worker1.port=8009\r\nworker.worker1.lbfactor=50\r\nworker.worker1.cachesize=10\r\nworker.worker1.cache_timeout=600\r\nworker.worker1.socket_keepalive=1\r\nworker.worker1.socket_timeout=300 \r\n<\/pre>\n<p>* Create <em>\/etc\/httpd\/conf.d\/mod_jk.conf<\/em> file:<\/p>\n<pre lang=\"bash\">\r\n# Load mod_jk module\r\nLoadModule    jk_module  modules\/mod_jk.so\r\n\r\n# Where to find workers.properties\r\nJkWorkersFile \/etc\/httpd\/conf\/workers.properties\r\n\r\n# Where to put jk shared memory\r\nJkShmFile     \/var\/log\/httpd\/mod_jk.shm\r\n\r\n# Where to put jk logs\r\nJkLogFile     \/var\/log\/httpd\/mod_jk.log\r\n\r\n# Set the jk log level [debug\/error\/info]\r\nJkLogLevel    info\r\n\r\n# Select the timestamp log format\r\nJkLogStampFormat \"[%a %b %d %H:%M:%S %Y] \"\r\n\r\n# Send all requests for context \/examples to worker named worker1\r\nJkMount  \/examples* worker1\r\n\r\n# Other mount examples:\r\n# Send servlet for context \/examples to worker named worker1\r\n#JkMount  \/examples\/servlet\/* worker1\r\n# Send JSPs  for context \/examples to worker named worker1\r\nJkMount  \/examples\/*.jsp worker1\r\n#JkMount \/webapp* ajp13\r\n#Mount the webapp context\r\n<\/pre>\n<p>* Check that all config files in <em>conf.d<\/em> directory is loaded in <em>httpd.conf<\/em> file:<\/p>\n<pre lang=\"bash\">\r\n#\r\n# Load config files from the config directory \"\/etc\/httpd\/conf.d\".\r\n#\r\nInclude conf.d\/*.conf\r\n<\/pre>\n<span id=\"Test\"><h2>Test<\/h2><\/span>\n<p>* Restart httpd<br \/>\nservice httpd restart<br \/>\n* Point browser to <a href=\"http:\/\/openidmbox\/examples\/\">http:\/\/openidmbox\/examples\/<\/a>. Note that we are using <em>port 80<\/em> instead of <em>port 8080<\/em>.<\/p>\n<span id=\"\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2014\/03\/mod_jk_config.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2014\/03\/mod_jk_config.jpg\" alt=\"mod_jk_config\" width=\"218\" height=\"163\" class=\"aligncenter size-full wp-image-9659\" \/><\/a><\/h6><\/span>\n<span id=\"References\"><h2>References<\/h2><\/span>\n<p>* <a href=\"http:\/\/tomcat.apache.org\/connectors-doc\/webserver_howto\/apache.html\">http:\/\/tomcat.apache.org\/connectors-doc\/webserver_howto\/apache.html<\/a><br \/>\n* <a href=\"http:\/\/archive.apache.org\/dist\/tomcat\/tomcat-connectors\/jk\/binaries\/linux\/\">http:\/\/archive.apache.org\/dist\/tomcat\/tomcat-connectors\/jk\/binaries\/linux\/<\/a><br \/>\n* <a href=\"http:\/\/tomcat.apache.org\/connectors-doc-archive\/jk2\/jk\/quickhowto.html\">http:\/\/tomcat.apache.org\/connectors-doc-archive\/jk2\/jk\/quickhowto.html<\/a><br \/>\n* <a href=\"http:\/\/anujjaiswal.wordpress.com\/2011\/06\/15\/configuring-mod_jk-tomcat-7-0-and-apache-2-2\/\">http:\/\/anujjaiswal.wordpress.com\/2011\/06\/15\/configuring-mod_jk-tomcat-7-0-and-apache-2-2\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Environment # cat \/etc\/redhat-release CentOS release 6.2 (Final) # uname -a Linux openidmbox.mytest.local 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU\/Linux # hostname openidmbox.mytest.local Prerequisites * Install Apache 2 # httpd -v Server version: Apache\/2.2.15 &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=9656\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[21,57],"tags":[465,467,466],"class_list":["post-9656","post","type-post","status-publish","format-standard","hentry","category-apache","category-tomcat","tag-apache2-2","tag-mod_jk","tag-tomcat7"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-2vK","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/9656","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9656"}],"version-history":[{"count":2,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/9656\/revisions"}],"predecessor-version":[{"id":9662,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/9656\/revisions\/9662"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}