Skip to main content

Apache and Tomcat Inegration in CentOS:

Apache the most popular open source web server and Tomcat the most popular open source application server for the Java application (JSP & Servlets).

Benefits to have a Apache Layer over the tomcat :

  • Static Content – Apache serves static content better than Tomcat and supports better caching mechanisms.
  • Availability – Apache allows load balancing and clustering of multiple Tomcat servers behind it, thus providing high availability.
  • Security – Apache protects Tomcat through its built-in security features and through advanced third-party modules such as ModSecurity.
  • Extensibility – Apache provides an abundance of modules for just about anything from URL rewriting (ModRewrite) to GeoIP services. With Apache you can use these modules to extend Tomcat's functionality.


Java installation :
1. download the latest JDK from Oracle's site
2. CentOS look for the package jdk-7u17-linux-x64.rpm (64-bit architecture) or jdk-7u17-linux-i586.rpm (32-bit architecture)
3.  Once you download the installation package, use the command 
rpm -ivh
4. Confirm you have the correct Java by running 
java -version


Tomcat installation

1. Download Apache Tomcat archive file from Apache tomcat official download page. You can use below wget command to download it.
cd /tmp 
wget http://www.us.apache.org/dist/tomcat/tomcat-7/v7.0.54/bin/apache-tomcat-7.0.54.tar.gz
2.After competed download extract archive file in /tmp directory and move to proper location as per your need. We are placing this under /usr/local directory.
tar xzf apache-tomcat-7.0.54.tar.gz
mv apache-tomcat-7.0.54 /usr/local/tomcat7
3.Tomcat by default start on port 8080, Make sure no other services are running on same port using ‘telnet localhost 8080'
cd /usr/local/tomcat7
./bin/startup.sh
4. Now access the tomcat home page  at http://localhost:8080/

Apache Installation:
1Enter the following command to install the Apache HTTP Server:
yum install httpd
2.  start the web server using command 
/etc/init.d/httpd start
3.To ensure that Apache starts following the next reboot cycle, issue the following command:
chkconfig httpd on
4. Now access the apache home page at http://localhost/



Apache and Tomcat Integration :

1. Open the server.xml file located at /usr/share/tomcat7/conf and add poxyPort to 80

<Connector port="8080"    proxyPort="80">

2. Open http.conf  file located at /etc/http/conf/ and add the proxyPass that redirect the apache request to tomcat.
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
3.  Now access  http://localhost/  you will see the tomcat home page.

Comments