Saturday, December 24, 2011
1:18 PM

Tomcat with Apache Integration on Linux server


# Installing and configuring mod_jk

To make connection between Tomcat and Apache, you will need to download and install mod_jk connector.
I chose to download the current source from the Apache archives:- http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/source/jk-1.2.15/
[root@map007 /]# cd /usr/local
[root@map007 local]# wget http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/source/jk-1.2.15/jakarta-tomcat-connectors-1.2.15-src.tar.gz
[root@map007 local]# tar -zxvf jakarta-tomcat-connectors-1.2.15-src.tar.gz
Change to the /usr/local/jakarta-tomcat-connectors-1.2.15-src/jk/native directory.
[root@map007 local]# cd jakarta-tomcat-connectors-1.2.15-src/jk/native
Now you are ready to create the custom configure file for your system. Execute the following:
[root@map007 local]# ./buildconf.sh
[root@map007 local]# ./configure –with-apxs=/usr/bin/apxs2
Now build the mod_jk with the following:
[root@map007 local]# make
Finally, if you were successful with the previous commands, copy the newly created mod_jk.soto your Apache2 modules directory. My modules were located at /usr/lib/apache2/modules.
[root@map007 /]# cp /usr/src/jakarta-tomcat-connectors-1.2.15-src/jk/native/apache-2.0/mod_jk.so /usr/lib/apache2/modules

# Configuring Tomcat and Apache

[root@map007 /]# vi /etc/apache2/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/apache2/httpd.conf
LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile /etc/apache2/workers.properties
# Where to put jk logs
JkLogFile /var/log/apache2/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-5.5.16
# 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/apache2 restart
You have Done all the Configurations.
Note :- Start Tomcat first: Always start Tomcat first and then start Apache.

References and paths:

Tomcat conf:
/usr/lib/apache-tomcat/conf/server.xml
Apache modules:
/usr/lib/apache2/modules
Apache conf:
/etc/apache2/workers.properties
/etc/apache2/httpd.conf
Tomcat stop and start:
cd /usr/local/apache-tomcat/bin
./shutdown.sh
./startup.sh
Apache2:
/etc/init.d/apache2 restart
/etc/init.d/apache2 stop
/etc/init.d/apache2 start

0 comments:

Post a Comment