Wednesday, February 17, 2021

Install Apache Tomcat mod_jk on CentOS

 How to install mod_jk module in Apache webserver on CentOS

Installing mod_jk on Apache (CentOs). 

Required software

  1. CentOS 7+
  2. Apache 2.4.x
  3. Tomcat Connectors 1.2.48

Installation

# yum install httpd-devel apr apr-devel apr-util apr-util-devel gcc make libtool autoconf

Get the latest source tarball:
# wget https://downloads.apache.org/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.48-src.tar.gz 
# wget https://downloads.apache.org/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.48-src.tar.gz.sha512

Check the integrity of the file:
# sha1sum -c tomcat-connectors-1.2.48-src.tar.gz.sha512
tomcat-connectors-1.2.48-src.tar.gz: OK

Extract the archive:
# tar xf tomcat-connectors-1.2.48-src.tar.gz 
# cd tomcat-connectors-1.2.48-src/native/
Get the path for apxs:
# which apxs
/usr/bin/apxs

Configure, compile and install:

# ./configure --with-apxs=/usr/sbin/apxs
# make
# libtool --finish /usr/lib64/httpd/modules
# make install

Configuration

Create file /etc/httpd/conf/workers.properties
Open the file /etc/httpd/conf/workers.properties and add the following to reflect your application details:
worker.list=appWorker1,appWorker2

worker.appWorker1.type=ajp13
worker.appWorker1.host=103.123.10.21
worker.appWorker1.port=8009
worker.appWorker1.socket_timeout=10
worker.appWorker2.type=ajp13
worker.appWorker2.host=105.123.10.22
worker.appWorker2.port=8009
worker.appWorker2.socket_timeout=10
Create mod_jk file at location /etc/httpd/conf/
e.g. /etc/httpd/conf/mod_jk.conf and add the following:
LoadModule jk_module modules/mod_jk.so

JkWorkersFile "/etc/httpd/conf/workers.properties"
JkLogFile     "/var/log/mod_jk.log"
JkLogLevel  info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions     +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat     "%w %V %T"

Restart Apache.
systemctl restart httpd.service

Check the log file mod_jk.log for any issues:

[Sun Dec 03 10:08:57 2017] [7005:140288381306848] [info] init_jk::mod_jk.c (3595): mod_jk/1.2.42 initialized












No comments:

Post a Comment