How to integrate tomcat with apache


Tomcat with Apache Integration on Linux server

To make connection between Tomcat and Apache, you will need to download and install mod_jk connector.

Download the current source from the Apache archives:-

[root@map007]# cd /usr/local

[root@map007]# http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/source/jk-1.2.6/jakarta-tomcat-connectors-jk-1.2.6-src.tar.gz

[root@map007 local]# tar -zxvf jakarta-tomcat-connectors-1.2.16-src.tar.gz

 Change to jakarta-tomcat-connectors-1.2.16-src/jk/native directory.

[root@map007 local]# cd /jakarta-tomcat-connectors-jk-1.2.6-src/jk/native

Now create the custom configure file for your system. Execute the following:

[root@map007 local]# ./buildconf.sh

[root@map007 local]# ./configure –with-apxs=/usr/sbin/apxs

Now build the mod_jk with the following:

[root@map007 local]# make

 Finally copy the newly created mod_jk.so to your Apache2 modules directory.

 [root@map007 /]# cp /root/jakarta-tomcat-connectors-jk-1.2.6-src/jk/native/apache-2.0/mod_jk.so /usr/lib/httpd/modules/

# Configuring Tomcat and Apache

[root@map007 /]# vi /etc/httpd/conf/workers.properties

workers.tomcat_home=/usr/lib/apache-tomcat
workers.java_home=/usr/lib/jdk
ps=/
worker.list=worker1
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1

# Save and close the file.

# Now you have to configure httpd.conf file and following lines.

[root@map007 /]# vi /etc/httpd/conf/httpd.conf

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile /etc/httpd/conf/workers.properties
# Where to put jk logs
JkLogFile /var/log/httpd/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat “[%a %b %d %H:%M:%S %Y] “

Save and close the file.

 Now a final security point.

[root@map007 /]# chown -R tomcat:tomcat /usr/lib/apache-tomcat

 # Now restart the Tomcat.

[root@map007 /]# cd /usr/local/tomcat/bin

[root@map007 bin]# ./shutdown.sh
[root@map007 bin]# ./startup.sh

 And restart Apache:

[root@map007 /]# /etc/init.d/httpd restart

Note: Always start Tomcat first before starting apache.

About Alex Hunt

Hi All I am Manish Kumar Jha aka Alex Hunt. I am currently working in VMware Software India Pvt Ltd as Operations System Engineer (vCloud Air Operations). I have around 5 Years of IT experience and have exposure on VMware vSphere, vCloud Director, RHEL and modern data center technologies like Cisco UCS and Cisco Nexus 1000v and NSX. If you find any post informational to you please press like and share it across social media and leave your comments if you want to discuss further on any post. Disclaimer: All the information on this website is published in good faith and for general information purpose only. I don’t make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this blog is strictly at your own risk. The Views and opinions published on this blog are my own and not the opinions of my employer or any of the vendors of the product discussed.
This entry was posted in Linux/CentOS. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s