Install Tomcat as Apache module on another port than 8080

D

Daniel

Hi

I am using:

- Tomcat 4.1.27
- Apache 2.0.44
- mod_jk-2.0.43.so

I installed Apache and Tomcat as described in the Apache/Tomcat/mod_jk
Howto (http://www.johnturner.com/howto/rh72-howto.html), without
compiling anything new. However I have a jboss server running on the
same machine which occupies port 8080, so I switched default Tomcat
port 8080 to 9080.

Has anybody an idea how to configure Apache/Tomcat so that port 9080
is used instead of the default one?

Best thanks for any hints.

Daniel Frey
 
S

Sudsy

Daniel said:
Hi

I am using:

- Tomcat 4.1.27
- Apache 2.0.44
- mod_jk-2.0.43.so

I installed Apache and Tomcat as described in the Apache/Tomcat/mod_jk
Howto (http://www.johnturner.com/howto/rh72-howto.html), without
compiling anything new. However I have a jboss server running on the
same machine which occupies port 8080, so I switched default Tomcat
port 8080 to 9080.

Has anybody an idea how to configure Apache/Tomcat so that port 9080
is used instead of the default one?

Look for the port attribute in your server.xml file. It might
be under one of the Connector tags.
 
J

Juha Laiho

(e-mail address removed) (Daniel) said:
That's where I have already changed the port to 9080. But might it be
that Apache has to know also which port (other than the default) has
to be taken to forward JSP and Servlet requests?

The 8080 port of Tomcat typially is where Tomcat provides its own HTTP
service - i.e. one that an be directly accessed from browsers. If you're
tunneling your Tomcat traffic through Apache (as it seems you are), you
should consider disabling this access method completely. This keeps the
image simpler: all requests to Tomcat must then arrive through the Apache
tunnel.

The Apache-Tomcat traffic is a different issue, and uses a different
port (8009 might have been one of the defaults for that). If your
Apache and Tomcat are located on the same machine, I recommend setting
this port to listen at localhost interface only.
 
S

Shawn McDermott

I was going to add this point as well. I noticed Daniel, that you
pointed out you were using mod_jk. With this mod, you no longer need
the standalone port 8080 or 9080 (or whatever) for tomcat.

so, are you using mod_jk or just using some port(8090) to talk to tomcat?

If mod_jk you will need to configure the jk stuff, ie
workers2.properties in apache.

I recently went down this path, so if need be, I can help. let me know.

shawn
 
D

Daniel

Thank you very much Shawn, Juha and Sudsy. I think I have
misunderstood some of the architectural traits of an Apache-Tomcat-JK
system. The reason I use port 8090 was to verify that the tomcat
installation is ok, as proposed in the installation manual at
http://www.johnturner.com/howto/rh72-howto.html. And indeed, the
verification is successful. The described verification process
proposes to call the server on this port, so I invoked
http://www.myserver.com:9080/examples, which is working. However,
invoking http://www.myserver.com/examples doesn't. I understand now,
that the port 9080 (or the standard port) is just necessary to invoke
tomcat directly, but not for the mod_jk to work.

Finally Shawn, the aim is to have a Apache with a tomcat module
(mod_jk) and without port 8080/9080, as Juha points out.

What I did so far:
1. I installed the three binary packages as mentioned in my first
posting.
2. I tested the installation. Apache works fine on its own, as does
tomcat on port 9080.
3. I configured server.xml as described in "Final Server
Configuration" of the RedHat Howto at the link given above.
4. I adapted the modJk attributes to the Listener tags to my server
configuration.
5. I changed the name attribute of the Host tag.
6. I made sure the server name of in httpd.conf matches
www.myserver.com
7. I added an "Include ..." line to httpd.conf after the LoadModule
block, but not at the very end (think this doesn't matter).
8. I created a workers.properties file in the conf/jk directory of
tomcat, copy past of the instructions of the howto.
9. I double checked that the mod_jk.conf file does get created upon
startup of tomcat in the conf/auto directory tomcat -> seems ok, as it
contains all sort of virtual hosts and directory directives which seem
to make sense.
10. I looked into the mod_jk.log file in the logs directory of tomcat:
0kb -> no error messages.
11. When I open apache's log/error_log then I see a line
"Apache/2.0.44 (Unix) DAV/2 PHP/4.3.1 mod_jk/1.2.2 configured --
resuming normal operations" upon startup -> the module has been
attached.
12. I restarted Apache and Tomcat several times, starting first
Tomcat, then Apache.

As it did not work, I supposed there may be something wrong with my
manipulatin at the direct-access port of Tomcat. However, I understood
in the meantime, that the mistake(s) must be somewhere else. Any hint,
test idea, debug tipp would be highly appreciated.

At the very end, I would like to attach a jboss module to Apache as
well :)

Thanks in advance
Daniel Frey
 
S

Shawn McDermott

First question: did you compile mod_jk2, or use a binary distribution?
I found that I could not get a binary distro to work, and had to build
mod_jk2 locally.

Second: do you have a workers2.properties file in $APACHE_HOME/conf ?
Assuming all other configuration is correct, this workers2.properties is
the main config for mod_jk2. This tells apache what urls to pass and to
what "worker" to pass them to.

for example:

www.johnturner.com:9080/examples works for tomcat standalone. for it to
work with mod_jk2 you would need the following in your
workers2.properties file:

[uri:/examples]
worker=ajp13:localhost:8009


Finally: if you check out your config and tomcats log shows that it is
listening on 8009 and apache shows that it is loading mod_jk2, then all
your work needs to be done in the workers2.properties. This file can be
a pain in the butt! If things don't work as you think they should, try
different mappings.....example from above [uri:/examples] might need to
look like [uri:/examples/*] or to load jsp's from a particular directory
you might need to map [uri:/examples/*.jsp]

basically, apache takes the url string and parses it against the
workers2.properties and determines where it needs to send the request.

Good luck. Also, there is a great book that just got published.

Tomcat: The Definitive Guide by Jason brittain and Ian F darwin.
ISBN: 0-596-00318-8

Shawn
 
S

Shawn McDermott

Another thought. are you using mod_jk or mod_jk2? if mod_jk then my
first reply does not apply. if you are not using mod_jk2 I would
suggest using it. it is a complete re-write and works much better.

Shawn
 
S

Shawn McDermott

mostly, I could never get mod_jk to work on my server. I got hooked up
with the auther of the book I mentioned, and we spoke about it and it
apeared to be versioning issues with apache and mod_jk. So, using the
latest apache build(at the time) and the latest mod_jk2, I rebuilt
everything and went from there. From what I saw, it is more
configurable, and easier to account for what is being served by apache,
and what is being served by tomcat via apache.

Shawn
 
S

Shawn McDermott

I think that is the most recent version. Did you build Tomcat locally
as well? You don't have to, but if you don't you will need to download
a lot of libraries that mod_jk2 needs to compile.

As for mod_webapp, it is not the "prefered" connection method. You
could also use mod_proxy, but again, it is slower, and not "prefered".

With mod_jk2 you can use either TCP sockets of UNIX sockets for
communication. the first is easier to implement, but the second is
faster. However, I have been using TCP sockets on my server and have
not run into any issues.

You are not alone when it comes to having issues getting tomcat and
apache to work well together. There are a lot of docs out on the web,
but I have found them lacking.

just curious, what os are your running?

Shawn
 
S

SS Tsay

Shawn said:
I think that is the most recent version. Did you build Tomcat locally
as well? You don't have to, but if you don't you will need to download
a lot of libraries that mod_jk2 needs to compile.

No, I downloaded it pre-built from here:

http://apache.mirrorcentral.com/dist/jakarta/tomcat-4/binaries/
With mod_jk2 you can use either TCP sockets of UNIX sockets for
communication. the first is easier to implement, but the second is
faster. However, I have been using TCP sockets on my server and have
not run into any issues.

What kind of machine is that? I am going to try this thing out on a
p200 w/ 128mb ram. I'm anticipating some performance problems, but I
don't know how bad. I have never run apache on anything less than an
athlon 1ghz.
You are not alone when it comes to having issues getting tomcat and
apache to work well together. There are a lot of docs out on the web,
but I have found them lacking.

Were there any that you remember being good? How did you get it all
together?
just curious, what os are your running?

Linux Mandrake 9.1.

Thanks,

TS
 
D

Daniel

Ok, I started over with jk2. Simpliest worker configuration on apache
side, production configuraiton of server.xml on tomcat side (both
according to http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk2/doc/jk2/vhosthowto.html).

It seems that there is a bug in the connector concerning the shared
memory, which I can observe in the error_log on apache:

[Fri Aug 15 00:08:06 2003] [error] shm.init(): No file
[Fri Aug 15 00:08:06 2003] [notice] Apache/2.0.47 (Unix) DAV/2
mod_jk2/2.0.0 configured -- resuming normal operations
[Fri Aug 15 00:08:06 2003] [error] shm.init(): No file
[Fri Aug 15 00:08:15 2003] [error] workerEnv.init() create slot
epStat.0 failed
[Fri Aug 15 00:08:15 2003] [error] lb.service() worker failed
ajp13:localhost:8009
[Fri Aug 15 00:08:15 2003] [error] lb.service() unrecoverable error...
[Fri Aug 15 00:08:15 2003] [error] mod_jk.handler() Error connecting
to tomcat 120000

The bug seems to be known
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19965), but an
interesting solution would be to add the required file manually. But
what is the name of this missing file and where has it to be put?

Another solution would be to recompile the jk2 module, however I was
not able to compile it because a "util" package does not exist.
Anybody has some input on compiling jk2?

Thanks a lot
Daniel Frey
 
S

Shawn McDermott

look through the ant build script and see waht packages it is needing.
if you don't have them. download and install, then try and rebuild.
This is the only way I got mine to work.

Shawn
 
S

Shawn McDermott

I am running redhat 9. My dev box is a athlon 2400 with 512gig ram. It
works very well.

Shawn
 
D

Daniel

Integration works now fine on the following configuration:

- SuSE Linux 8.0
- Apache httpd 2.0.47 from source
- Tomcat 5.0.7 binaries (certainly older version will work also)
- mod_jk2 2.0.43 binary
(http://jakarta.apache.org/builds/ja...lease/v2.0.1/bin/linux/i386/mod_jk2-2.0.43.so)
- Howto (http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk2/doc/jk2/vhosthowto.html)

The problem with the shm file is resolved too (see Howto). Add it to
the workers2.properties file like that:

[shm]
file=/usr/local/apache/logs/shm.file
size=1048576

Hope that helps.
Daniel Frey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top