vicker313 tech blog

September 12, 2013

Setup Tomcat with Apache Web Server in Linux

Filed under: Apache, Tomcat — Tags: , , — vicker313 @ 11:08 pm

Tutorial below show how to setup Apache Tomcat as back-end and Apache Web Server as front-end at your Web Server. In this way user can run both PHP and JSP in one single server without setting up different ports, and also make use of the advantage of Apache Web Server Modules like Mod Security. All the installation files mentioned below are in source code format, however you may also install using respective Linux package manager.

(This tutorial is assumed Tomcat is already installed in the server, located at /apache-tomcat)

  1. First of all, install httpd by running command below inside the httpd extracted directory  (get it from http://httpd.apache.org). The SSL feature is optional (httpd will be installed at /usr/local/apache2).
    • ./configure –enable-ssl –enable-so –with-ssl=/usr/local/ssl
    • make
    • make install
  2. Troubleshoot: the following packages are missing during my installation of httpd, for your reference
    • install apr
      • ./configure
      • make
      • make install
    • install apr-util
      • ./configure –with-apr=/usr/local/apr
      • make
      • make install
    • install pcre
      • ./configure –disable-cpp
      • make
      • make install
  3. Install tomcat-connectors (to create mod_jk.so)
    • in terminal, change directory to native folder in the extracted directory and issue following commands:
      • ./configure –with-apxs=/usr/local/apache2/bin/apxs
      • make
      • make install
    • copy native/apache-2.0/mod_jk.so to /usr/local/apache2/modules (it might auto put it into the folder during the installation)
    • copy conf/httpd-jk.conf to /apache-tomcat/conf/mod_jk.conf
    • copy conf/workers.properties to /apache-tomcat/conf/workers.properties
    • edit /usr/local/apache2/conf/httpd.conf
      • add line “Include /apache-tomcat/conf/mod_jk.conf”
    • edit /apache-tomcat/conf/mod_jk.conf (this is the part to specify which url to refer Apahce Tomcat, eg jspSystem)
      • JkWorkersFile workers.properties
      • add line “JkMount /jspSystem/* balancer”
      • add line “JkMount /jspSystem/ balancer”
    • edit /apache-tomcat/conf/workers.properties
      • worker.node1.port=8009
      • worker.node2.activation=D
  4. Set Apache Tomcat to run at port 8080.
  5. Now you can start Apache Web Server (like using this command /usr/local/apache2/bin/apachectl -k start)

 

Advertisements

Create a free website or blog at WordPress.com.