|
Search:
Advanced search
|
Browse by category:
|
Contact Us |
Configuring mod_jk for apache in Cpanel server ? |
|||||
What is mod_jk?
mod_jk act as a connector between apache and tomcat. This module handles the communication between apache and tomcat. Configuring mod_jk for apache in cpanel server ------------------------------------------------------------------- mod_jk can be obtained in two formats - source and binary. I prefer using source :) -------------------------------------------------------------- cd /usr/local/src/ wget http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/source/jk-1.2.15/jakarta-tomcat-connectors-1.2.15-src.tar.gz tar -xzf jakarta-tomcat-connectors-1.2.15-src.tar.gz cd jakarta-tomcat-connectors-1.2.15-src cd jk/native/ ./configure --with-apxs=/usr/local/apache/bin/apxs make cd apache-1.3/ cp mod_jk.so.0.0.0 /usr/local/apache/libexec/mod_jk.so cd ../../conf/ cp workers.properties /usr/local/apache/conf/workers.properties -------------------------------------------------------------- Now create a file jk.conf in /usr/local/apache/conf/ Edit the file jk.conf and enter this: ---------------------------------------------------------------------------- JkWorkersFile /usr/local/apache/conf/workers.properties JkLogFile /usr/local/apache/logs/mod_jk.log JkLogLevel info JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories JkRequestLogFormat "%w %V %T" ---------------------------------------------------------------------------- Make sure you you specify the correct path for JkWorkersFile (i.e /usr/local/apache/conf/workers.properties) Now edit /usr/local/apache/conf/httpd.conf and add this under corresponding section ------------------------------------------------------ Include "/usr/local/apache/conf/jk.conf" LoadModule jk_module libexec/mod_jk.so AddModule mod_jk.c ------------------------------------------------------ Now if you want to add support for jsp files for a domain add the following lines inside the virtual host entry for that domain in /usr/local/apache/conf/httpd.conf -------------------------------- JkMount /*.jsp ajp13 JkMount /servlet/* ajp13 -------------------------------- For example: -------------------------------------------------------------- <VirtualHost 192.168.1.1:80> ServerName domain.com ServerAlias www.domain.com ServerAdmin webmaster@domain.com DocumentRoot /home/domain/public_html JkMount /*.jsp ajp13 JkMount /servlet/* ajp13 BytesLog /usr/local/apache/domlogs/domain.com-bytes_log CustomLog /usr/local/apache/domlogs/domain.com combined ScriptAlias /cgi-bin/ /home/domain/public_html/cgi-bin/ </VirtualHost> -------------------------------------------------------------- Edit the file /usr/local/apache/conf/workers.properties Check the following : -------------------------------------------------------------------- workers.tomcat_home=/usr/local/tomcat/ ( should be the path to tomcat) workers.java_home=/usr/local/jdk1.6/jdk ( you will get this path by `echo $JAVA_HOME` ) ------------------------------------------------------------------- Next thing you need to check is need a virtual host entry in the server.xml (tomcat file) cd /usr/local/tomcat/conf edit server.xml file and add the following under Virtual Hosts -------------------------------------------------------------- <Host name="domain.com" appBase="/home/domain/public_html/"> <Context path="" reloadable="true" docBase="/home/domain/public_html/" debug="1"/> <Context path="/manager" debug="0" privileged="true" docBase="usr/local/jakarta/tomcat/server/webapps/manager"> </Context> </Host> -------------------------------------------------------------- Now to test if mod_jk is working properly just put a test jsp page in /home/domain/public_html/test.jsp and access it via URL http://domain.com/test.jsp test.jsp code is as below: -------------------------------------------------------------- <HTML> <HEAD> <TITLE>Jsp sample page- Hello </TITLE> </HEAD> <BODY"> <P> <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR> <B><CENTER><FONT COLOR=BLACK SIZE=5> <TABLE BORDER BGCOLOR=BLACK> <TR> <TD ALIGN=CENTER VALIGN=CENTER> <B><FONT COLOR=RED SIZE=5> <% out.println(" Hey it's working!!!"); %> ! </B> </TD> </TR> </TABLE> </CENTER></B> </P> </BODY> </HTML> -------------------------------------------------------------- That's all ;) |
|||||
Powered by
Deru Communications (Webhosting Knowledgebase)