How do I run Apache (httpd) and Tomcat together? How do I run Apache (httpd) and Tomcat together? apache apache

How do I run Apache (httpd) and Tomcat together?


  • Have Tomcat listen on a port other than 80
  • Follow a guide to set up mod_proxy to redirect requests for a certain location to Tomcat, such as this one.

If you're really just testing, skip the second step and just access the server via a different port for Tomcat.

edit: See also http://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html on setting up mod_proxy_ajp.


You neglected to mention what version of Tomcat you're using and you also didn't mention whether you actually looked at the Tomcat documentation to answer the question.

I'd suggest starting here: http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html and look into setting up mod_jk.


If you want to use apache/ httpd to serve the request from PHP as well as any other server running on different port let say tomcat on port 8080 you can use apache/ httpd to act as a "proxy" and map a URL which will be served by another server. This is done using ProxyPass ProxyPassReverse configuration.

For example:If you want http://localhost/php to be served by PHP and http://localhost/tomcat to be served by tomcat then you will have to make following changes in httpd.config/ apache.config [apache2.config depending on version of apache you are using]:

LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_balancer_module modules/mod_proxy_balancer.soLoadModule proxy_http_module modules/mod_proxy_http.so# Uncomment these to proxy FTP or HTTPS#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so#LoadModule proxy_connect_module modules/mod_proxy_connect.so<VirtualHost *:80># Your domain name# ServerName Domain_NAME_HEREProxyPreserveHost OnProxyPass /tomcat http://localhost:8080/ProxyPassReverse /tomcat http://localhost:8080/# The location of the HTML files, and access control informationDocumentRoot /var/www<Directory /var/www>    Options -Indexes    Order allow,deny    Allow from all</Directory></VirtualHost>

In case you are running httpd on centos and you may get error Apache Mod_proxy '[Error] (13)Permission Denied', then follow this link which says execute the following command:

 /usr/sbin/setsebool -P httpd_can_network_connect 1

I would recommand you to read mod_proxy.

Ref: Redhat mod_proxy configuration