Novell Home

Integrating Apache 2.0.x and Tomcat 4.1.x using mod_jk connector on SUSE 9

Novell Cool Solutions: Feature
By Thomas Yeung

Rate This Page

Reader Rating  stars  from 3 ratings

Digg This - Slashdot This

Posted: 14 Jan 2004
 

Thomas Yeung is a Software Enginer at Novell, Inc.

Update: We have made a correction to Step 12.

  1. By default, SUSE Linux Server 9 bundles with the Sun Java SDK. Hence, all we need to do is to set up the environment variable JAVA_HOME to point to the Java SDK directory. Edit the /etc/profile file add the JAVA_HOME variable at the end of the file:

    export JAVA_HOME=/usr/lib/SunJava2-1.4.2

  2. Type "source /etc/profile" in the shell.


  3. Ensure the Apache 2.0.47 is installed on your system already. If not, use YaST (Install and Remove Software) to install the software. Select "Simple Webserver with Apache2" option in Selections filter.


  4. Install Jakarta Tomcat from YaST. Select "Package Groups" filter in "Install and Remove Software". Select "zzz All" from Package Groups. Check the "apache2-jakarta-tomcat-connectors" and "jakarta-tomcat" packages. The two packages will be installed from the SUSE Linux Server 9 CDs.


  5. Testing Tomcat by running the startup.sh from the Tomcat directory:

    Type "/opt/jakarta/tomcat/bin/startup.sh" in the shell.


  6. Open a web browser and enter "http://localhost:8080" as the URL and you should see the Tomcat web page.


  7. Edit the Tomcat server.xml file with your preferred editor:

    e.g. vi /opt/jakarta/tomcat/conf/server.xml


  8. Add the following lines immediately after the <Server port="8005"?> declaration:


  9. <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig"
          modJk="/usr/lib/apache2/mod_jk.so" jkDebug="info"
          workersConfig="/opt/jakarta/tomcat/conf/workers.properties"
          jkLog="/opt/jakarta/tomcat/logs/mod_jk.log"/>
  10. Comment out (using <-- and --> ) the following paragraph after this declaration:


  11. <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
    <!--  (add this)
        <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
                   port="8009" minProcessors="5" maxProcessors="75"
                   enableLookups="true" redirectPort="8443"
                   acceptCount="10" debug="0" connectionTimeout="0"
                   useURIValidationHack="false"
                   protocolHandlerClassName="org.apache.jk.server
                   .JkCoyoteHandler"/>
    --> (add this)
  12. Uncomment the following paragraph after this declaration:


  13. <!-- Define an AJP 1.3 Connector on port 8009 -->
    
    	<!-- (remove this)
          	<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
    	      port="8009" minProcessors="5" maxProcessors="75"
    	      acceptCount="10" debug="0"/>
    	--> (remove this)
  14. Finally, add the following lines after <Host name="localhost"> declarations, add a listener:


  15.       <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" 
          append="true"  />
  16. Create a directory called "jk" under /opt/jakarta/tomcat/conf


  17. Edit workers.properties file in the /opt/jakarta/tomcat/conf directory and make it look like the following:


  18. workers.CATALINA_HOME=/opt/jakarta/tomcat
    workers.java_home=$(JAVA_HOME)
    ps=/
    
    worker.list=ajp13
    worker.ajp13.port=8009
    worker.ajp13.host=localhost
    worker.ajp13.type=ajp13
    worker.ajp13.lbfactor=1
    
    worker.loadbalancer.type=lb
    worker.loadbalancer.balanced_workers=ajp13
    worker.inprocess.type=jni
    worker.inprocess.class_path=$(workers.CATALINA_HOME)$(ps)lib$(ps)tomcat.jar
    worker.inprocess.cmd_line=start
    worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)classic$(ps)libjvm.so
    worker.inprocess.stdout=$(workers.CATALINA_HOME)$(ps)logs$(ps)inprocess.stdout
    worker.inprocess.stderr=$(workers.CATALINA_HOME)$(ps)logs$(ps)inprocess.stderr
  19. Stop and start Tomcat using shutdown.sh and startup.sh in the Tomcat bin directory. If everything worked correctly, you will now have a mod_jk.conf file in /opt/jakarta/tomcat/conf/auto directory.


  20. Edit the httpd.conf file to include mod_jk.conf. Add the following lines to the end of the LoadModule section:


  21. Include /opt/jakarta/tomcat/conf/auto/mod_jk.conf

  22. Test httpd.conf by typing the following:


  23. /etc/init.d/apache2 configtest

  24. Restart Apache2 by enter the following:


  25. /etc/init.d/apache2 restart

  26. Open a web browser and test the mod_jk connector.


  27. http://localhost/examples

Reader Comments

  • Great work. Good that it's there. Thanks Thomas. Adding the location of httpd.conf in step 15 would be nice and for the icing on the cake a sentence concernig the possibility to stop tomcat being reachable under the 8080 port would be great

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

Novell® Making IT Work As One

© 2008 Novell, Inc. All Rights Reserved.