Sunday, October 5, 2008

Run Tomcat Server Under Apache Server

In this post I am trying to give you information of running tomcat server under apache server on LINUX. If you want to do so then follow these instructions:

  1. First of all get Apache HTTP server from apahce site http://httpd.apache.org and apache tomcat server from http://tomcat.apache.org
  2. Install both Apache and Tomcat servers on your system.
  3. Now get tomcat connector from http://tomcat.apache.org/download-connectors.cgi
  4. Now start extracting tomcat connectors file and installing it on bash shell:
  5. $gunzip tomcat-connecters-x.x.xx-src.tar.gz
  6. $tar -xvf tomcat-connecters-x.x.xx-src.tar
  7. $cd tomcat-connecters-x.x.xx-src/native
  8. $./configure --with-apxs=APACHE_PATH/bin/apxs
  9. $make (compiling the installation files)
  10. $make install (installing files)
  11. $cp apache 2.0/mod_jk.so APACHE_PATH/modules
  12. Now configuring Tomcat server:
  13. $vi TOMCAT_PATH/conf/server.xml
  14. In this file add
    <Listener classname="org.apache.jk.config.ApacheConfig" modJk="APACHE_PATH/modules/mod_jk.so"/ >
    in
    <engine name="Catalina" defaulthost="localhost">...<engine> block.
  15. Restart tomcat server if it is running: $./TOMCAT_PATH/bin/shutdown.sh then $./TOMCAT_PATH/bin/startup.sh
  16. Now doing Tomcat configuration
  17. $vi TOMCAT_PATH/cont/auto/mod_jk.conf
  18. Copy appropriate JkMount files from block to outside of it. eg JkMount /abc ajp13
  19. Now configuring Apache server
  20. Open apache configuration file $vi APACHE_PATH/conf/httpd.conf
  21. Add following line at the end of file: Include TOMCAT_PATH/conf/auto/mod_jk.conf
  22. Also add LoadModule jk_module modules/mod_jk.so in httpd.conf file.
  23. Restart Apache server: $/usr/sbin/apachectl restart
  24. And you have dont it!!!
Now you can run tomcat server applications with the layer of apache server such as if you are running http://localhost:8080/tomcat_project then now you can run it as http://localhost/tomcat_project you will get redirected to your project.

Reference:
http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html




No comments: