3
votes

I'm using Apache2 (Ubuntu) and Tomcat to serve up web applications. Currently, my /etc/apache2/ports.conf has only the default port listening (Listen 80). If I use the url http://hostname:80/webAppName my browser just keeps clocking saying "waiting on hostname". I believe the default port for Tomcat is 8080, do I need to add 8080 to to ports.conf or change Tomcats default port. Any ideas?

4

4 Answers

1
votes

I dont have experience with Tomcat but Googling I've found this:

Install mod-jk; the apache 2 connector. This is the package that connects apache with tomcat.

apt-get install libapache2-mod-jk

Once this is installed, you need to configure it. Add these lines to /etc/apache2/apache2.conf

# Worker properties file
JkWorkersFile /etc/apache2/workers.properties

# Logging
JkLogFile /var/log/apache2/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel info

# Log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

you need to modify workers.properties file, so that it knows where to find your tomcat install. You need to point your worker to your tomcat and java directories, and specify the port (8080 in this case) that it is running on.

workers.tomcat_home=/usr/local/tomcat/tomcat
workers.java_home=/usr/lib/jvm/java-6-sun
ps=/
worker.list=worker1

worker.default.port=8080
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1

Now, go back into /etc/apache2/apache2.conf, and add in the tomcat context's you wish to share. Unfortunately (as far as I know) you cant translate to different contexts (i.e your TestContext in apache must translate to TestContext in tomcat. If you wish to translate it, you'll need to do use apaches (awesome) module mod_rewrite.)

# Send servlet for context / TestContext to worker named worker1

JkMount /TestContext worker1
JkMount /TestContext/* worker1

JkMount /AnotherContext worker1
JkMount /AnotherContext/* worker1

Restart apache (/etc/init.d/apache2 restart). Now, any requests sent to apache (i.e http://myserver/TestContext), will be forwarded through to tomcat.

1
votes

You are missmatching Apache HTTPD (a webserver, mostly referenced as apache or apache2) and Apache Tomcat (a java servlet engine)!

To access the application on tomcat you have to access the port configured in tomcat (usually 8080 for http): http://hostname:8080/application

If you want to access tomcat applications through the httpd then you have to configure httpd to proxy your requests. How this could be done can be seen in my answer to this question.

0
votes

Web Application is a dynamic extension of a web or application server that provides a way for the marketers to get to know the people visiting their sites. Web Application

0
votes

I think this is a suitable solution to change the port numbers of apache tomcat. I used this tutorial http://beginlinux.com/server/ubuntu/changing-the-port-on-tomcat and it worked for me.