Saturday, April 2, 2016

Apache Tomcat Integration Mod_Jk Llinux

 installating tomcat,apache and integrating both
INSTALLATION STEPS


Required files

   httpd-2.2.13.tar.gz
  apache-tomcat-6.0.20.tar.gz
  jdk-6u16-linux-i586.bin
  jakarta-tomcat-connectors-1.2.15-src.tar.gz




Installing Java and Tomcat


              JAVA
             -------

  1.              First change the permission of the downloaded file
                        
                         chmod +x jdk-6u16-linux-i586.bin

  2.              Now execute the file
                        
                         ./jdk-6u16-linux-i586.bin

  3.              It will create you a folder named "jdk1.6.0_16" in the path where you have done the prev                    step.

  4.              Move the folder to your desired path
             
                         mv jdk1.6.0_16 /usr/local/jdk1.6.0_16

  5.              Set JAVA_HOME environment variable in /etc/profile file.
                                   
                                    now we r done with java.



             TOMCAT
        -----------


   1.              First extract the downloaded tar file "apache-tomcat-6.0.20.tar.gz"

                         eg:- tar xvzf apache-tomcat-6.0.20.tar.gz

   2.              Move the extracted directory to your desired path

                         mv apache-tomcat-6.0.20 /usr/local/apache-tomcat-6.0.20

   3.              Set environment variable for tomcat(CATALINA_HOME) in /etc/profile file

   4.              Try starting tomcat by giving the following command
                        
                         /usr/local/apache-tomcat-6.0.20/bin/./startup.sh

   5.              If every thing went fine,by giving

                                    http://localhost:8080/

              you should be able to c the tomcat page.


                        



Installaing Apache


By default, if you have done a full installation of ORACLE ENTERPRISE LINUX apache will be preinstalled, Its better to remove it( yum uninstall httpd) and install a never version.




  1.      Untar the httpd-2.2.13.tar.gz file (tar xvzf httpd-2.2.13.tar.gz)

  2.     Get into the directory created during extraction (eg : cd /root/Desktop/httpd.2.2.13)

  3.     Configure apache for installation by giving
                        
               ./configure --prefix=/usr/local/apache

  4.    Next is to make the files
                        
                     make

  5.    Now install the apache server
                        
                   make install

  6.    If the installation goes correctly, folders will be created in /usr/local/apache or the               
path you gave during configuration.

  7.    Now try to start the apache server by giving
             
          /usr/local/apache/bin/apachectl start

  this will start your apache server, open your browser and check if apache is                                     
started
                        
            http://localhost





Integrating Tomcat and Apache using jk connector.




  1.   Extract the downloaded “jakarta-tomcat-connectors-1.2.15-src.tar.gzfile to

eg:- jakarta-tomcat-connectors-1.2.15-src.tar.gz


  1. Create the custom configure file for your system

./buildconf.sh

  1. Now configure the connector with apxs(it will be available in apache’s bin folder)

./configure --with-apxs=/usr/local/apache/bin/apxs

  1. Now we should build the mod_jk

make

  1. If every thing worked as planned we can find the mod_jk.so in apache-2.0 directory inside the connector.
Move the created file to apache modules directory

cp /usr/src/ jakarta-tomcat-connectors-1.2.15-src/jk/native/apache-2.0/mod_jk.so  /usr/local/apache/modules

  1. Create a workers file in apache home directory

touch  /usr/local/apache/workers.properties

  1. Include the following line inside the properties file.

workers.tomcat_home=/usr/local/ apache-tomcat-6.0.20/
workers.java_home=/usr/local/jdk1.6.0_16
ps=/
worker.list=worker1


worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1






  1. Now open the /usr/local/apache/conf/httpd.conf file and add the following lines.

LoadModule jk_module /usr/local/apache/modules/mod_jk.so


# Where to find workers.properties
JkWorkersFile /usr/local/apache/workers.properties


# Where to put jk logs (create dir named apache if not avail)
JkLogFile /var/log/apache/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] "


# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories


# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"


# Send servlet for context /yourproject to worker named worker1
JkMount /projectname worker1
# Send JSPs for context /jsp-examples/* to worker named worker1
JkMount /projectname /* worker1


  1. Include the following line inside the catalina.sh  file in tomcat /lib folder

JAVA_OPTS="$JAVA_OPTS -javaagent:$CATALINA_HOME/lib/spring-agent.jar"

  1. Move the follwing jar files in tomcat/lib folder

              spring-agent.jar
spring-tomcat-weaver to tomcat/lib folder

Now Start your tomcat and apache servers.

If you give http://localhost/projectname it should work fine.





workers.tomcat_home=/usr/local/apache-tomcat-6.0.20/
workers.java_home=/usr/local/jdk1.6.0_16
ps=/
worker.list=worker1,ajp13
worker.ajp13.port=8009
#worker.ajp13.host=10.100.101.195
worker.ajp13.host=dmacseaplx01.dmac.wdssvcs.com
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=5

No comments:

Post a Comment