Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I recently got projects that runs on Struts and I am expecting more JSP coming ahead.

After googling the question, I was led to blogs of people who tried to do the same. Those blogs weren't exactly a step by step procedure of how they did it but more like a reference in case they need to do something the same in the future. In some cases, the author didn't exactly say if he was successful in his attempt to run both aforementioned services together.

Unfortunately, I can't follow their "instructions" as I have plenty of PHP projects configured (upload directories, classpaths etc...) to run on my test server and I don't have the luxury of time to reconfigure them all in case I mess up with the httpd server. And for honesty's sake, I haven't tried a single step on running them together for the same reason of being hesitant to update configuration files.

I'm not sure if this adds to the complexity but I am running both services thru xampp (with tomcat being a xampp add-on) for portability purposes.

I know that I can just stop my Apache service whenever I am working on JSP but hey this is an oppurtunity to try something new and I just can't let it slip. Further, it would really be convenient for both services to just run automatically on startup which would really increase my productivity as I won't have to manually switch between services when needed.

Hope there's someone on SO who rode the same boat.

edit: Tomcat Version is 6.0.20 Httpd Version is 2.2.14

like image 723
lock Avatar asked Aug 17 '10 01:08

lock


People also ask

Does Tomcat use Apache HTTPd?

Tomcat is a web server of its own, so a separate web server like Apache is not required. You probably will want to change Tomcat's port though, since it defaults to 8080 and web sites are usually on port 80.

Can Apache and Tomcat run on same port?

You cannot configure Tomcat to use the same port. An alternative would be to configure Apache to work as a reverse proxy for a specific location. For instance, make all requests going to /myapp to be routed or bridged to Tomcat which would be running on a different port.

Is Tomcat and HTTPd same?

Key difference between Tomcat and the Apache HTTP Server the Apache HTTP Server, but the fundamental difference is that Tomcat provides dynamic content by employing Java-based logic, while the Apache web server's primary purpose is to simply serve up static content such as HTML, images, audio and text.


2 Answers

  • 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.

like image 159
Borealid Avatar answered Oct 13 '22 00:10

Borealid


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.

like image 25
user334583 Avatar answered Oct 13 '22 01:10

user334583