Activities

February 2015
M T W T F S S
« Jan   Mar »
 1
2345678
9101112131415
16171819202122
232425262728  

How do I install mod_jk on Apache 2.4 webserver

Today I got a task to host java application on a AWS Linux server. While I’m installing Apache, I found that Apache 2.2 is outdated and it does not have capabilities binding multiple SSL in a single elastic IP ( My projects having 4 SSL sites) and hence I can not use Apache 2.2 on this server. So I decide to go ahead with Apache 2.4 version.

How do I install Apache 2.4

[root@-db01 ~]# yum install httpd24
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main/latest                                         | 2.1 kB     00:00
amzn-updates/latest                                      | 2.3 kB     00:00
================================================================================
 Package             Arch         Version                 Repository       Size
================================================================================
Installing:
 httpd24             x86_64       2.4.10-1.59.amzn1       amzn-main       1.3 M
Installing for dependencies:
 apr                 x86_64       1.5.0-2.11.amzn1        amzn-main       115 k
 apr-util            x86_64       1.4.1-4.14.amzn1        amzn-main        87 k
 httpd24-tools       x86_64       2.4.10-1.59.amzn1       amzn-main        85 k
 mailcap             noarch       2.1.31-2.7.amzn1        amzn-main        27 k

Transaction Summary
================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 1.6 M
Installed size: 4.2 M
Is this ok [y/d/N]:

How do I enable SSL support on Apache

It’s a confusing installation as anyone who familiarize with Apache with execute the command “yum install mod_ssl” . While executing this command it will throw an error that Apache 2.2 has to be installed. So if you are using Apache 2.4 , you need to use the command “yum install mod24_ssl” rather than using “yum install mod_ssl” old one.

[

root@adhi-db01 ~]# yum install mod24_ssl
Loaded plugins: priorities, update-motd, upgrade-helper
Resolving Dependencies
Dependencies Resolved
================================================================================
 Package            Arch        Version                    Repository      Size
================================================================================
Installing:
 mod24_ssl          x86_64      1:2.4.10-1.59.amzn1        amzn-main      107 k
Installing for dependencies:
 apr                x86_64      1.5.0-2.11.amzn1           amzn-main      115 k
 apr-util           x86_64      1.4.1-4.14.amzn1           amzn-main       87 k
 httpd24            x86_64      2.4.10-1.59.amzn1          amzn-main      1.3 M
 httpd24-tools      x86_64      2.4.10-1.59.amzn1          amzn-main       85 k
 mailcap            noarch      2.1.31-2.7.amzn1           amzn-main       27 k
Transaction Summary
================================================================================
Install  1 Package (+5 Dependent packages)
Total download size: 1.7 M
Installed size: 4.4 M
Is this ok [y/d/N]:

3. How do I install mod_jk Tomcat connector on Apache 2.4 server.

Unfortunately there is no any binary available for Apache 2.4 currently. So we have to compile mod_jk from the source code. So I’m doing this for the first time and expecting it would be helpful for anyt newbie in future 🙂

Download mod_jk source code from http://www.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.40-src.tar.gz . While you creating config. file you may need to use this parameter ” ./configure –with-apxs=/usr/bin/apxs”.

[root@adhi-web01 native]# yum install gcc*
[root@adhi-web01 native]# wget http://apache.bytenet.in/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.40-src.tar.gz
[root@adhi-web01 native]# tar -zxvf tomcat-connectors-1.2.40-src.tar.gz
[root@adhi-web01 native]# cd tomcat-connectors-1.2.40-src
[root@adhi-web01 native]# cd native
[root@adhi-web01 native]#  ./configure --with-apxs=/usr/bin/apxs
[root@adhi-web01 native]# make && make install

This will install mod_jk.so on “/usr/lib64/httpd/modules/mod_jk.so” path and you may need to add this on a apache config. file. Here I create a file “jk.conf” on /etc/httpd/conf.d/” folder having the following lines

[root@adhi-web01 ~]# cat /etc/httpd/conf.d/jk.conf
LoadModule jk_module  /etc/httpd/modules/mod_jk.so
JkWorkersFile /etc/httpd/conf.d/workers.properties
JkShmFile     /var/log/httpd/mod_jk.shm
JkLogFile     /var/log/httpd/mod_jk.log
JkLogLevel    info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
[root@adhi-web01 ~]#

4. Webserver setup and creating workers.properties file

Now you need to create two other empty files for logging.

[root@adhi-web01 ~]# touch /var/log/httpd/mod_jk.shm /var/log/httpd/mod_jk.log

Also you need to create a worker file on the same path “/etc/httpd/conf.d”. Here are my entries.

[root@adh-web01 conf.d]# cat workers.properties
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
[root@adhi-web01 conf.d]#

5. Creating Tomcat host configuration file (/usr/local/Apache_Tomcat/conf/server.xml)

<Host name="test.com" appBase="/home/test/public_html"
autoDeploy="true" unpackWARs="true"
xmlValidation="false" xmlNamespaceAware="false"  >
<Alias>www.test.com</Alias>
<Context path="/newapp" docBase="."/>
 <Context path="/images" docBase="/home/eyeonyourhome/public_html/images"/>
 </Host>

6. Creating Apache virtualhost config. file (/etc/httpd/conf.d/javahost.conf) for Java hosting

<VirtualHost *:80>
ServerName test.com
ServerAlias www.test.com
DocumentRoot /home/test/public_html
DirectoryIndex index.html
Alias /  /home/test/public_html
JkMount /*.jsp worker1
JkMount /* worker1
</VirtualHost>

Install java and set the necessary variables for Tomcat. Restart both Tomcat and Apache and you will see the magic 🙂

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>