# Integrate Tomcat With Apache Using mod_jk

## MrStaticVoid

Integrate Tomcat With Apache Using mod_jk

Before you begin

These instructions were written for Tomcat 4.1.  Since the time of this writing a new version of Tomcat, Tomcat 5, has been released.  In Tomcat 5, mod_jk2 is the perfered linking method.  Continue reading this thread for more information about mod_jk2.

What will be done?

By default Tomcat is setup to use port 8080.  In order to let users view your JSP or Servlet pages, they would have to navigate outside of your main Apache site.  This also made using SSL in Java pages an impossibility.  When linking your Tomcat server with your Apache server, Apache forwards its *.jsp and */servlet/* requests to Tomcat using an intermediate module, mod_jk.  There is a more advanced module called mod_jk2 available, but due to its lack of any documentation, very few servers use it.  mod_jk is preferred.

Setup Apache

If you already have Apache setup, great, skip this section.  Otherwise just

```
# emerge sync

# emerge apache

# rc-update add apache2 default

# /etc/init.d/apache2 start
```

Goto http://localhost to see if Apache works.  You can also use Apache 1.3, however I have not tested it and I'll leave it up to you to figure out the best way to include the configuration information.

Setup Tomcat

In the following section you will setup the JSP and Servlet server, Tomcat 4.1.

```
# emerge tomcat
```

There is a bug in the default permissions for a configuation file that does not allow Tomcat to start.

```
# chmod 755 /etc/conf.d/tomcat
```

Now set Tomcat to load at startup and start the server.

```
# rc-update add tomcat default

# /etc/init.d/tomcat start
```

Goto http://localhost:8080 to see if Tomcat works.

mod_jk will only work with Tomcat >= 4.0.  If you are not using a JDK from Portage, you may have to specify your JDK's path in /etc/conf.d/tomcat.

Compile mod_jk

Download the latest source to mod_jk and unpack:

```
$ wget http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk/release/v1.2.4/src/jakarta-tomcat-connectors-jk-1.2.4-src.tar.gz

$ tar -xvzf jakarta-tomcat-connectors-jk-1.2.4-src.tar.gz
```

Now you'll have to prepare your system for the build.

```
# mkdir /usr/build

# updatedb

# locate config_vars.mk
```

The config_vars.mk file should be in something like /usr/lib/apache2/build/ but it may be in a different location if you use Apache 1.3.  Copy that file to /usr/build/

```
# cp /usr/lib/apache2/build/config_vars.mk /usr/build/
```

Now we'll compile.

```
$ cd jakarta-tomcat-connectors-jk-1.2.4-src/jk/native/

$ ./buildconf.sh

$ ./configure --with-apxs=/usr/sbin/apxs2

$ make
```

If you are using Apache 1.3 you need to use the configure flag '--with-apxs=/usr/sbin/apxs'.

Now copy the module to a place safe place:

```
# cp apache-2.0/mod_jk.so /usr/lib/apache2-extramodules/
```

Now the fun begins...link 'em up!

Open up /opt/tomcat/conf/server.xml in your favorite text editor.  After the  line

 *Quote:*   

> <Server port="8005" shutdown="SHUTDOWN" debug="0">

  add

 *Quote:*   

> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" />

 

and after the line

 *Quote:*   

> <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true">

 

add

 *Quote:*   

> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" append="true" />

 

Save the file and restart Tomcat.

```
# /etc/init.d/tomcat restart
```

Wait about a minute (I'm serious...I don't care how fast your computer is) for Tomcat to parse the configuration.  You should now have directories called 'auto' and 'jk' in /opt/tomcat/conf/.  Copy /opt/tomcat/conf/auto/mod_jk.conf to /etc/apache2/conf/modules.d/.  Delete every thing in your newly copied mod_jk.conf except for the JkMount lines.  Edit that file to look something like:

 *Quote:*   

> <IfDefine JK>
> 
>         <IfModule !mod_jk.c>
> 
>                 LoadModule jk_module    extramodules/mod_jk.so
> ...

 

As you see in the new mod_jk.conf there a line defining where the workers.properties file is.  The workers.properties is a file that specifies mod_jk's linking type, ports, and loadbalancers if you want them.  I have created the most simple workers.properties as possible.  You should create this file in /opt/tomcat/conf/jk/.

 *Quote:*   

> workers.tomcat_home=/opt/tomcat
> 
> workers.java_home=/opt/blackdown-jdk-1.4
> 
> ps=/
> ...

 

Change the paths as necessary.  To enable mod_jk in Apache, edit /etc/conf.d/apache2 to have

 *Quote:*   

> APACHE2_OPTS="-D JK"

 

Make sure APACHE2_OPTS is uncommented!  Now restart Apache and navigate to http://localhost/tomcat-docs/.  Since tomcat-docs has been "JkMount"ed, Apache will forward requests to Tomcat.  If you see the Tomcat documentation, then everything has been set up correctly.

Well so much for my first post to the documentation forum.  Please give me comments or ask me questions.Last edited by MrStaticVoid on Sat Apr 24, 2004 9:21 pm; edited 2 times in total

----------

## Lehren

.. everything worked just fine. Thank you!

Two things:

1) Emerging apache and tomcat adds users to your system, make sure you address the default passwords.

2) The only mistake I made was missing the 'extralibs' path to in the new mod_jk.conf file. I'd highlight that as an existing line that needs to be changed.

----------

## aent

For those of you who want mod_jk2 you can basicly follow the instructions above, but it does require some modifications to it:

This is basicly what I did:

```
# wget http://apache.mirrors.pair.com/jakarta/tomcat-connectors/jk2/jakarta-tomcat-connectors-jk2-src-current.tar.gz

# tar -xvzf jakarta-tomcat-connectors-jk2-src-current.tar.gz

# mkdir /usr/build

# ln -s /usr/bin/libtool /usr/build/libtool

# cp /usr/lib/apache2/build/config_vars.mk /usr/build/

# cd jakarta-tomcat-connectors-jk2-2.0.2-src/jk/native2/

# chmod 0777 buildconf.sh

# ./buildconf.sh

# ./configure --with-apxs2=/usr/sbin/apxs2

# make clean build

# libtool --finish /usr/lib/apache2

# cp ../build/jk2/apache2/mod_jk2.so /etc/apache2/extramodules/

# cp ../build/jk2/apache2/jkjni.so /etc/apache2/extramodules/

# cp /opt/tomcat/conf/auto/mod_jk.conf /etc/apache2/conf/modules.d/

```

Now you'll need to modify the mod_jk.conf file... Basicly delete everything but <IfModule !mod_jk2.c> .. </IfModule>, which jk_module needs to be changed to jk2_module and the path to mod_jk2.so needs to be corrected...

Add 

```
<VirtualHost *>

<Location /*.jsp">

JkUriSet worker ajp13:localhost:8009

</Location>

</VirtualHost>
```

Next we'll need to modify server.xml to include the Apache-Tomcat service.

Add this below <Server port="8005" shutdown="SHUTDOWN" debug="0">:

```
  <Service name="Tomcat-Apache">

 

   <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->

    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"

               port="8009" minProcessors="5" maxProcessors="75"

               enableLookups="true" redirectPort="8443"

               acceptCount="10" debug="0" connectionTimeout="20000"

               useURIValidationHack="false"

               protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>

   <Engine name="Apache" defaultHost="localhost" debug="0">

      <Logger className="org.apache.catalina.logger.FileLogger"

              prefix="apache_log." suffix=".txt"

              timestamp="true"/>

     <!-- Access log processes all requests for this virtual host. -->

      <Valve className="org.apache.catalina.valves.AccessLogValve"

                 directory="logs"  prefix="localhost_access_log." suffix=".txt"

                 pattern="common" resolveHosts="false"/>

   <Host name="localhost" debug="0"

appBase="/home/httpd/htdocs" 

       unpackWARs="true" autoDeploy="true">

      <Alias>localhost</Alias>

      <Alias>www</Alias>

      <Alias>10.0.0.10</Alias>

      <Context path="" docBase="" debug="1"/>

      <Valve className="org.apache.catalina.valves.AccessLogValve"

                 directory="logs"  prefix="home_access_log." suffix=".txt"

                 pattern="common" resolveHosts="false"/>

   </Host>

</Engine>

</Service>
```

Add this to jk2.properties:

```

# list of needed handlers.

handler.list=channelSocket,request

# Override the default port for the channelSocket

channelSocket.port=8009

```

In /etc/apache2/conf/ make a file called workers2.properties and stick this inside:

```
[logger.apache2]

level=DEBUG

[shm]

file=/etc/apache2/logs/shm.file

size=1048576

[channel.socket:localhost:8009]

port=8009

host=127.0.0.1

[ajp13:localhost:8009]

channel=channel.socket:localhost:8009

```

Restart tomcat and apache2 and everything should be good to go!

----------

## jwever

The method for mod_jk2 worked for me  except I had to change the following ...

 *Quote:*   

> # ./configure --with-apxs2=/usr/sbin/apxs2 

 

to 

```
# ./configure --with-apxs2=/usr/sbin/apxs2 --with-tomcat41=/opt/tomcat
```

----------

## cederberg

This bug might be of interest, as it contains an ebuild for mod_jk2.

----------

## brondsem

If you are running your computer with a hostname other than localhost (e.g., csx.calvin.edu) then you need to change /opt/tomcat/conf/auto/mod_jk.conf to reflect this.

<VirtualHost csx.calvin.edu>

     ServerName csx.calvin.edu

......

......

----------

## AllTom

Brilliant. Amazing. I can't believe this post made it so easy! Thank you very, very much!!   :Very Happy: 

----------

## fatpiper

I saw the post on using VirtualHost in order to make this useful for hosts other than localhost ...  Could somebody please post some more details on where this VirtualHost directive goes?

Thanks!

----------

## frequency

I've tried both examples of how to configure Apache2 and Tomcat, in both instances the servers don't give me an errors but I am unable to get the tomcat engine to handle the request.

<HTML>

<BODY>

Testing JSP

 <% System.out.println("HELLO WORLD"); %>

Ending Test

</BODY>

</HTML>

Outputs: Testing JSP Ending Test 

This file is inside /var/www/localhost/htdocs/jsptest/

I'm not sure if permissions have anything to do with it, But I gave the file 755.

If anyone could help me out I would appreciate it, I'm still very new to the linux enviorment

-Thank You for your time

----------

## Ulukai

Hi,

Thanks for sharing your knowledge.

I had some problems during the build..

After the attempt to install mod_jk with the suggestions posted from "Mr. Static Void" (which failed), I tried to follow the suggestions posted by "aent". 

All steps but one succeeded.

There was no file named /opt/tomcat/conf/auto/mod_jk.conf after all.

There was not even a directory called /opt/tomcat/conf/auto

I´m using Tomcat 4.1 and Apache2 and followed your suggestions step by step and also tried 

./configure --with-apxs2=/usr/sbin/apxs2 --with-tomcat41=/opt/tomcat

but that didn´t work. 

I would be very glad if someone could help me.

Thanks in advance,

Ulukai

----------

## MrStaticVoid

frequency,

To clear things up: there is no way to get Apache to send the JSP to Tomcat for parsing in the way the Apache sends PHP to the PHP interpreter.  Your JSP must go into a webapp of Tomcat.  Then you can setup mod_jk to forward requests from Apache to Tomcat for the JSP.

For example, for my website I created a webapp called the_static_void. 

```
# mkdir /opt/tomcat/webapps/the_static_void /opt/tomcat/webapps/the_static_void/WEB-INF
```

Then I put the following text into WEB-INF/web.xml:

 *Quote:*   

> <?xml version="1.0" encoding="ISO-8859-1"?>
> 
> <!DOCTYPE web-app
> 
>         PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> ...

 

That tells Tomcat about your webapp and maps Servlet requests.

From there plop your JSP's into the root of your webapp.  You should be able to see them by going to http://localhost:8080/<webappname>/<jspname>.jsp

Then to have Apache see it, follow the instructions of my original post, adding the JkMount lines for your webapp mod_jk.conf.  After restarting Apache, you should be able to see your JSP by going to http://localhost/<webappname>/<jspname>.jsp

Easy, eh?

Ulukai,

The auto directory should appear after you modify your server.xml as per my original post, and restart Tomcat.  Try again and report your success or failure.

I'm happy some people are finding my post useful!    :Very Happy: 

----------

## frequency

I get a Internal Server Error when I try to view the tomcat page. My /opt/tomcat/conf/auto/mod_jk.conf always gets overwritten and in my catalina.log i have

 *Quote:*   

> INFO: Initializing Coyote HTTP/1.1 on port 8080
> 
> mod_jk location: libexec/mod_jk.so
> 
> Make sure it is installed corectly or  set the config location
> ...

 

I dont see anythign in my /var/log/apache2/error_log file

any ideas?

----------

## albanard

I've followed the instructions but make fails with this message:

libtool: install: error: cannot install `../../../build/jk2/apache2/libjkjni.la' to a directory not ending in /usr/lib/apache2

Does anyone know how to get around this?

Versions Tried:

jakarta-tomcat-connectors-jk2-2.0.2-src

(also tried jakarta-tomcat-connectors-4.1.29-src)

bash-2.05b# libtool --version

ltmain.sh (GNU libtool) 1.4.3 (1.922.2.111 2002/10/23 02:54:36)

(also tried:  1.4.1)Last edited by albanard on Tue Feb 17, 2004 12:05 pm; edited 1 time in total

----------

## christsong84

i can't find the connecter file anywhere  :Sad: 

----------

## albanard

The connector source mentioned for jk2 is:

http://apache.mirrors.pair.com/jakarta/tomcat-connectors/jk2/jakarta-tomcat-connectors-jk2-src-current.tar.gz

Your local mirror can be naviagted to from:

http://jakarta.apache.org/site/sourceindex.cgi

OLD:

Do you mean the connector source tar.gz file? I think the latest is 4.1.30 , but I've been having better luck with 4.1.29 apart from my libtool problem above. Anyway here is a  link: http://www.apache.org/dist/jakarta/tomcat-4/v4.1.29/src

----------

## albanard

EDIT: THIS PROBLEM IS NOW FIXED IN THE LATEST CVS SOURCES AVAILABLE AT: http://cvs.apache.org/snapshots/jakarta-tomcat-connectors/

I tried downgrading libtool and it didn't help:

bash-2.05b# libtool --version

ltmain.sh (GNU libtool) 1.4.1 (1.922.2.34 2001/09/03 01:22:13)

This seems like such a stupid problem, does anyone know a workaround? I still get the dreaded:

libtool: install: error: cannot install `../../../build/jk2/apache2/jkjni.la' to a directory not ending in /usr/lib/apache2

make[1]: *** [../../../build/jk2/apache2/jkjni.so] Error 1Last edited by albanard on Sat Apr 17, 2004 1:31 pm; edited 1 time in total

----------

## Tarantula

I emerged apache 2 and tomcat 5, but I can't find the /opt/tomcat/conf/auto/ directory !   :Sad: 

Could you tell me where the "mod_jk.conf" is in tomcat 5 ?

Could you mind tell me how to use tomcat5 with jakarta-tomcat-connectors-jk2-2.0.2 ?

Should I use other connector for tomcat5 with apache 2 ?

----------

## tomarsyd

I've installed jboss-3.2.3.tgz (includes Tomcat 4.1.29 JBossWeb HTTP server and JSP/Servlet engine, EJB, CMP2.0, JCA, IIOP, Clustering, JTA, JMX and more)

and have successfully built mod_jk2.so according to the very nicely explained directions above (Thank you Mr. Static Void)

On one of the last steps in his description (on the third post, his follow-up post) he says to cp /opt/tomcat/conf/auto/mod_jk.conf /etc/apache2/conf/modules.d/ 

First of all there was no mod_jk.conf file included in any of the packages I downloaded, and secondly, there is no /opt/tomcat/... directory because I haven't installed Tomcat explicitly, It came in the jboss package. 

What do I do here? 

You can also see my question on the Jboss forums at:

http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3822808#3822808

Any help is much appreciated.

----------

## JCScoobyRS

To get mod_jk to work with Tomcat 5, just make the changes to the listener's className to look like:

org.apache.jk.config.ApacheConfig

instead of:

org.apache.ajp.tomcat4.config.ApacheConfig

Everything else in the tutorial is valid.  Just follow the instructions and make those changes and all will be well.  Laters, Jeremy

----------

## 9uSt00

Hello.. i just installed tomcat by

```
emerge tomcat
```

that worked just fine.

Then, when i went into the /opt/tomcat/bin directory and untarred the jsvc.tar.gz file, changed to the src dir, and configured without any problems. The problem i found was when i ran 'make'. There's a bug in the native/home.c file on line 110 where a semi colon has been left out. so i changed 

```
        /* Format changed for 1.4 JVMs */

        sp = strchr(ret, ' ');

        if(sp != NULL)

            *sp = '\0'

```

to 

```
        /* Format changed for 1.4 JVMs */

        sp = strchr(ret, ' ');

        if(sp != NULL)

            *sp = '\0';    /* <---- here */

```

Restarting apache2 works perfectly, but I'm not able to start tomcat. The /etc/init.d/tomcat start command simply outputs:

```
 * Starting Tomcat...

Using CATALINA_BASE:   /opt/tomcat

Using CATALINA_HOME:   /opt/tomcat

Using CATALINA_TMPDIR: /opt/tomcat/temp

Using JAVA_HOME:       /opt/sun-jdk-1.4.2.03
```

But the funny thing is that when i do a ps axf, i don't see the tomcat processes at all. In addition, my syslog shows this:

```
Mar  5 03:23:25 [su(pam_unix)] session opened for user tomcat by root(uid=0)

Mar  5 03:23:25 [su(pam_unix)] session closed for user tomcat

Mar  5 03:23:25 [kernel] grsec: From xxx.xxx.xxx.xxx: signal 11 sent to (java:16471) UID(265) EUID(265), parent (init:1) UID(0) EUID(0)
```

I'm assuming that since i have the GrSecurity options in the kernel set to meduim, they're causing some problems, but i'm not sure what to do. Any suggestions?

cheers.

----------

## 9uSt00

Ok, so i removed the Grsecurity settings from my kernel, recompiled, installed and rebooted.  Now, i don't get that error anymore, but tomcat still does not want to start.

Digging through the logs, i found that the problem seems to be the code defining the Coyote connector in the /opt/tomcat/conf/server.xml from aent's howto:

```
   <Service name="Tomcat-Apache">

        <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->

        <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8009"

        ....

        </Service>

```

(pause)

Ok, so i found (ref. https://forums.gentoo.org/viewtopic.php?t=137977) that (naturally enough) the connector classname has to be changed from org.apache.coyote.tomcat4.CoyoteConnector to org.apache.coyote.tomcat5.CoyoteConnector.

The problem now, is that i get a 404 by tomcat when i try to access any documents in the tomcat server (eg. /tomcat-docs, /jsp-examples, /servlet-examples).

i found this in /var/log/tomcat/catalina.log:

```
INFO: Starting Coyote HTTP/1.1 on port 8080

Mar 5, 2004 2:59:30 PM org.apache.jk.common.ChannelSocket init

INFO: Port busy 8009 java.net.BindException: Address already in use

Mar 5, 2004 2:59:30 PM org.apache.jk.common.ChannelSocket init

INFO: JK2: ajp13 listening on /0.0.0.0:8010

Mar 5, 2004 2:59:30 PM org.apache.jk.server.JkMain start

INFO: Jk running ID=1 time=0/5  config=/opt/tomcat/conf/jk2.properties

Mar 5, 2004 2:59:30 PM org.apache.catalina.startup.Catalina start
```

seems that 8009 is already in use... i don't know tomcat 5, so i don't really know where to start looking...  Either way it says that it starts on port 8010 instead, but i guess that the link is thus broken, since the tutorial configures the link between tomcat and apache to be on port 8009... right?

can anyone please help?

gustavo

----------

## AnthonyZEO

Thanks Mr. Static Void for the instructionson mod_jk.  I had previously run Apache/Tomcat 4 on Mandrake with mod_jk2, which brings me to...

Thanks JCScoobyRS for the tip on getting this to work with Tomcat 5.

Great thread, very helpful.  Thanks to everyone that participates.

----------

## JCScoobyRS

Anthony,

     Just glad I could help.  I searched doc after doc from Apache looking for the change and finally found something from an old mail archive.  Good luck, Jeremy

----------

## new2linux

Hello.  I've been following the code posted by "aent" but when I get to the step

"# cp /opt/tomcat/conf/auto/mod_jk.conf /etc/apache2/conf/modules.d/ "

it says that the file or directory does not exist.  After further inspection I realized that I don't even have an "auto" directory.  Did I miss something in my setup somewhere?  Could this file be somewhere else?

Any help would be appreciated.

Thanks

----------

## pvincent

Still stuck with jk2   :Crying or Very sad: 

I emerged apache ( v2.0.48 ) and tomcat ( v5.0.18 ) succesfully.

/etc/init.d/apache2 start  -> OK on port 80

/etc/init.d/tomcat start     -> OK on port 8080

I installed the testing phase ebuild mod_jk2 provided by Gentoo:bugzilla into my ${PORTDIR_OVERLAY}.

Then, I could emerge mod_jk2 (v2.0.2) -> SUCCESS

And now, what should do I do next ?

Documentation from tomcat is quite tricky.

Where to describe the relationship between apache and tomcat ?

I suppose I need to add some extra parameters into : 

/etc/apache2/conf/workers2.properties

/etc/apache2/conf/modules.d/105_mod_jk2.conf

/etc/tomcat/jk2.properties

/etc/tomcat/server.xml

The documentation above are mainly focused either to previous version of jk or tomcat 4.x.

Need extra help...

----------

## pvincent

Finally, I succeed.  :Smile: 

And it was easier than expected.

Most of things are done through emerge mod_jk2.

Here is my short experience which I relate below :

check PORTDIR_OVERLAY if uncommented in /etc/make.conf

PORTDIR_OVERLAY=/usr/local/portage

then download testing phase ebuild and miscelleanous files into ${PORTDIR_OVERLAY}/net-www/mod_jk2

like this :

/usr/local/portage/net-www/mod_jk2/mod_jk2-2.0.2.ebuild

/usr/local/portage/net-www/mod_jk2/files/workers2.properties

/usr/local/portage/net-www/mod_jk2/files/105_mod_jk2.conf

/usr/local/portage/net-www/mod_jk2/files/mod_jk2-server-apache2-Makefile.in.patch

ebuild /usr/local/portage/net-www/mod_jk2/mod_jk2-2.0.2.ebuild digest

emerge mod_jk2

nano /etc/conf.d/apache2

	>>APACHE2_OPTS="... -D JK2"

nano /etc/apache2/conf/workers2.properties

	>>	# Uri mapping

		[uri:/<your webapp>/*]

		worker=ajp13:localhost:8009

/etc/init.d/apache2 restart

There are still some errors complaining about jk2_init() in /var/log/apache2/error_log, but from certain sources, it seems to be irrelevant...http://www.mail-archive.com/tomcat-user%40jakarta.apache.org/msg117578.htmlLast edited by pvincent on Fri Mar 26, 2004 5:47 am; edited 1 time in total

----------

## `djinn`

I am trying to figure out how to remove the 

"Servlet-Engine:" header. It is running under apache. I just don't like the kernel version, along with other version info being revealed. I have looked around and can't find anything on this  :Sad:  Any help would be greatly appreciated  :Smile: 

----------

## najk

This is what i had to do to get it all running.

Downloaded java from https://www6.software.ibm.com/dl/lxdk/lxdk-p

```

        rpm -ivh IBMJava2-SDK* 

        rpm -ivh IBMJava2-JAAS* 

        rpm -ivh IBMJava2-JAVACOMM*

        export JAVA_HOME=/opt/IBMJava2-141

        export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin

        wget http://apache.archive.sunet.se/dist/jakarta/tomcat-5/v5.0.18/bin/jakarta-tomcat-5.0.18.tar.gz

        tar zxf jakarta-tomcat-5.0.18.tar.gz

        mv jakarta-tomcat-5.0.18 /opt/tomcat5

        tar zxf jakarta-tomcat-connectors-jk-1.2.4-src.tar.gz

        cd jakarta-tomcat-connectors-jk-1.2.4-src/jk/native/ 

        ./buildconf.sh 

        ./configure --with-apxs=/usr/sbin/apxs2 

        make

        cp ../build/jk2/apache2/mod_jk2.so /opt/apache2/modules

Then in server.xml i had to add many virtual host for getting it working with my virtual host list.

inside <Engine name="Catalina" defaultHost="localhost">

  <Host name="www.najk.net" debug="0"

  appBase="/opt/wwwsites/najk.net" unpackWARs="true" autoDeploy="true">

  <Context path="/" docBase="/opt/wwwsites/najk.net" debug="1"/>

  <Alias>najk.net</Alias>

  </Host>

```

Repeated for each host..

Just thougt if someone lookt for multiple virtual host config.

//Najk

http://najk.com/[/code]

----------

## pvincent

About virtual hosting, I did the same :

a host containing an unique context / for one webapp.

I had to repeat this config. for each distinct webapp.

Has anybody found a better solution to do virtual hosting between apache and tomcat ?

----------

## BlinkEye

 *aent wrote:*   

> For those of you who want mod_jk2 you can basicly follow the instructions above, but it does require some modifications to it:
> 
> This is basicly what I did:
> 
> Add this below <Server port="8005" shutdown="SHUTDOWN" debug="0">:
> ...

 

what should i do with 

```
className="org.apache.coyote.tomcat4.CoyoteConnector"
```

 as i've installed tomcat 5(.0.18)?

----------

## BlinkEye

 *pvincent wrote:*   

> Finally, I succeed. 
> 
> And it was easier than expected.
> 
> Most of things are done through emerge mod_jk2.
> ...

 

i think none of your ebuilds work (any more). 

```
HTTP request sent, awaiting response... 404 Not Found

00:34:43 ERROR 404: Not Found.

!!! Couldn't download jakarta-tomcat-connectors-jk2-2.0.2-src.tar.gz. Aborting.
```

anyway, to get it working change the line from the ebuild which read 

```
SRC_URI="http://www.apache.org/dist/jakarta/tomcat-connectors/jk2/source/jakarta-tomcat-connectors-jk2-${PV}-src.tar.gz"
```

to 

```
SRC_URI="http://apache.mirrors.pair.com/jakarta/tomcat-connectors/jk2/jakarta-tomcat-connectors-jk2-src-current.tar.gz"
```

----------

## BlinkEye

damn. it doesn't work:

```
emerge mod_jk2

Calculating dependencies ...done!

>>> emerge (1 of 1) net-www/mod_jk2-2.0.2 to /

>>> md5 src_uri ;-) jakarta-tomcat-connectors-jk2-src-current.tar.gz

>>> Unpacking source...

>>> Unpacking jakarta-tomcat-connectors-jk2-src-current.tar.gz to /var/tmp/portage/mod_jk2-2.0.2/work

/usr/sbin/ebuild.sh: line 19: cd: /var/tmp/portage/mod_jk2-2.0.2/work/jakarta-tomcat-connectors-jk2-2.0.2-src/jk/native2: No such file or directory

RUNNING FROM extra_functions.sh

 * Applying mod_jk2-server-apache2-Makefile.in.patch...

 * Failed Patch: mod_jk2-server-apache2-Makefile.in.patch!

 *

 * Include in your bugreport the contents of:

 *

 *   /var/tmp/portage/mod_jk2-2.0.2/temp/mod_jk2-server-apache2-Makefile.in.patch-18268.out

!!! ERROR: net-www/mod_jk2-2.0.2 failed.

!!! Function epatch, Line 360, Exitcode 0

!!! Failed Patch: mod_jk2-server-apache2-Makefile.in.patch!

```

----------

## tfunk

I followed aent's post, but something went wrong and I'm to noob to figure it out...

I have no mod_jk.conf and no jkjni.so

so when I get to the step of copying them it bombs out.

Can someone suggest what I have to do to fix it?

Thanks for all the info!

Tfunk

----------

## pvincent

Have you tried mod_jk2-2.0.4 ebuild ?

Just download the tbz2 file; then untar into /usr/local/portage/net-www/.

I had to append "apache2" into the USE variable before it detects apache2

Then emerge mod_jk2, it should work.

By the way, you'd better follow advices directly from Gentoo BUGZILLA.

Or wait for a stable ebuild

----------

## tfunk

warning....stupid noob question...

How long does it normally take to get a stable ebuild?

there's an app I'll need to run that requires java (tomcat/apache/etc), I'm new to the linux world, so I don't know what all is envolved in waiting for a new stable ebuild.

If we are talking a week or two then I can wait no problem...much longer than that and I'll need to figure out another solution.

Any ideas?

Thanks!

----------

## pvincent

Here is your answer : http://www.gentoo.org/doc/en/ebuild-submit.xml

----------

## coreutils

I am running Apache 1.3. I had to put 

"Include /etc/apache/conf/addon-modules/mod_jk.conf"

at the end of /etc/apache/conf/apache.conf to get it going.

 :Shocked: 

----------

## SmokinBudda

Well, after much toiling I have a more or less operational mod_jk2.  I'm able to run the jkstatus page, but nothing else.  I hope someone here can tell me where I've gone wrong.

I've edited my /etc/apache2/conf/modules.d to read

```

<IfModule !mod_jk.c>

  LoadModule jk2_module /etc/apache2/extramodules/mod_jk2.so

</IfModule>

<VirtualHost *>

  <Location /*.jsp">

    JkUriSet worker ajp13:localhost:8009

  </Location>

</VirtualHost>

```

I added this to /opt/tomcat/server.xml

```

  <Service name="Tomcat-Apache">

 

   <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->

    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"

               port="8009" minProcessors="5" maxProcessors="75"

               enableLookups="true" redirectPort="8443"

               acceptCount="10" debug="0" connectionTimeout="20000"

               useURIValidationHack="false"

               protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>

   <Engine name="Apache" defaultHost="localhost" debug="0">

      <Logger className="org.apache.catalina.logger.FileLogger"

              prefix="apache_log." suffix=".txt"

              timestamp="true"/>

     <!-- Access log processes all requests for this virtual host. -->

      <Valve className="org.apache.catalina.valves.AccessLogValve"

                 directory="logs"  prefix="localhost_access_log." suffix=".txt"

                 pattern="common" resolveHosts="false"/>

   <Host name="localhost" debug="0"

appBase="/home/httpd/htdocs"

       unpackWARs="true" autoDeploy="true">

      <Alias>localhost</Alias>

      <Alias>www</Alias>

      <Alias>10.0.0.10</Alias>

      <Context path="" docBase="" debug="1"/>

      <Valve className="org.apache.catalina.valves.AccessLogValve"

                 directory="logs"  prefix="home_access_log." suffix=".txt"

                 pattern="common" resolveHosts="false"/>

   </Host>

</Engine>

</Service>

```

Of course prior to this edit I had also made the changes to server.xml suggested by Mr. Static Void.  (Do I need to remove those changes after mod_jk.conf has been generated?)

My /opt/tomcat/conf/jk2.properties reads:

```

handler.list=channelSocket,request

channelSocket.port=8009

serverRoot=/etc/apache2

apr.NativeSo=/etc/apache2/extramodules/libjkjni.so

```

My workers.properties says:

```

# workers2.properties

# Shared memory handling. Needs to be set.

[shm]

file=/etc/apache2/logs/shm.file

size=1048576 

[channel.socket:localhost:8009]

port=8009

host=127.0.0.1

[ajp13:localhost:8009]

channel=channel.socket:localhost:8009

# Announce a "status" worker

[status:status]

info=Status worker. Displays runtime information.

[uri:/jkstatus/*]

group=status:status

# Uri mapping

[uri:/btp/*]

[uri:/admin/*]

```

The uri mappings I got from http://www.reliablepenguin.com/clients/misc/tomcat/  (I tried it both ways really)

Anyhoo, the jkstatus target works just fine, but none of the others do.  Is there something that any of you can see I'm missing?

Thanks!

----------

## SmokinBudda

In case you were wondering, I got it to work.  Apparently it helps to name files properly...

Who knew   :Smile: 

I also changed my jk2.properties to read

```

# jk2.properties

# Configured for channel UNIX

# Set the desired handler list

handler.list=apr,request,channelUnix

# UNIX Domain socket location

channelUnix.file=/opt/tomcat/work/jk2.socket

# Dynamic Library

serverRoot=/etc/apache2

apr.NativeSo=/etc/apache2/extramodules/libjkjni.so

```

I also changes workers.properties to read

```
# workers2.properties

# Shared memory handling. Needs to be set.

[shm]

info=Scoreboard. Required for reconfiguration and status with multiprocess serve

rs

file=/opt/tomcat/logs/jk2.shm

size=1048576

debug=0

disabled=0

# UNIX domain socket

[channel.un:/opt/tomcat/work/jk2.socket]

tomcatId=localhost:8009

debug=0

# define the worker

[ajp13:/opt/tomcat/work/jk2.socket]

channel=channel.un:/opt/tomcat/work/jk2.socket

# Announce a "status" worker

[status:status]

info=Status worker. Displays runtime information.

[uri:/jkstatus/*]

group=status:status

# Uri mapping for BTP

[uri:/btp/*]

```

I also removed the settings that were added to server.xml

Maybe I did some other stuff too.  Stupid memory...

----------

## mathiasb

For the people having trouble with the /opt/tomcat/conf/auto directory not being generated using tomcat5 . I had the same trouble, but i noticed that the second line you have to find in /opt/tomcat/conf/server.xml looks like this:

```
<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">

```

instead of this:

```
<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true">

```

Removing the two xml* options fixed it for me and now the directory gets generated.   :Smile: 

----------

## Darkstar

I'm a systems admin for my company who is relatively new to Linux and Gentoo. I am trying to get the mod_jk2 connector to work. I've read everything on these boards about it and looked at a lot on the web. I can't seem to get it going and would love some help. 

I'm running apache 2.0.49 and tomcat 5.0.18. I emerged apache and tomcat normally. I followed instructions in this thread to insert the ebuild and emerge mod_jk2-2.0.4. Apache is up and responding on port 80. Tomcat is up and responding on 8080. My problem is getting both to work together. I haven't emerged any other packages than those required by these 3 ebuilds from portage. 

I've tried to piece together the correct How-To from reading all the theads and from looking at the Jakarta site but it's not working. It seems that the instructions are drawn from different versons of these packages so it's very difficult for me. I know I'm close to the solution. 

Could someone please post the final steps required for apache2 and tomcat 5? Thanks for any help you can pass on.

----------

## SmokinBudda

Hey peeps!

I wanted to let ya'll know that I ended changing my setup quite a lot from the last configuration files that I posted.  While the other one worked (kinda) it didn't do what I wanted it to, and I presume that any of you who were foolish enough to listen to me earlier are having the same trouble.

First a bit about my setup.  I have two domains www.foo.com and www.bar.com.  I want to be able to have tomcat serve anything that I explicitly want it to serve, but not everything.  For example I want it to execute jsp files that are part of a webapp, not jsp files I may post in a tutorial.

I'm running Apache2.0.49 and Tomcat 5.0.18.

I'm assuming that have been able to build mod_jk.so.  If you haven't I can recommend that you read this entire thread and glean the correct settings from there.  It's what I did, and I then promptly forgot how I did it.  Sorry.

First I shutdown tomcat and apache (which were working in standalone mode before I began)

```

/etc/init.d/apache2 stop

/etc/init.d/tomcat stop

```

Next I set up my directories

```

/var/www/foo/

/var/www/bar

chgrp -R apache /var/www/foo

chgrp -R apache /var/www/bar

```

Note: you will need to add the apache user to the tomcat group.  Do this how you feel comfortable, I edited the /etc/groups file by hand.  I also added tomcat to the apache group just in case, I doubt it's needed.

I moved mod_jk2.so and libjkjni.so into /etc/apache2/extramodules/

I edited /etc/apache2/conf/apache2.conf

Below the last LoadModule section I added

```

###

### New Modules added by SBudda

###

LoadModule jk2_module /etc/apache2/extramodules/mod_jk2.so

```

I also uncommeted 

```
Include conf/vhosts/vhosts.conf
```

Next I edited /etc/apache2/conf/vhosts/vhosts.conf

```

################# Named VirtualHosts

NameVirtualHost 192.168.1.3

<VirtualHost 192.168.1.3>

  ServerName www.foo.com

  ServerAlias foo.com *.foo.com

  DocumentRoot /var/www/foo

  <Directory /var/www/foo>

    <IfModule mod_access.c>

      Order allow,deny

      Allow from all

    </IfModule>

  </Directory>

</VirtualHost>

<VirtualHost 192.168.1.3>

  ServerName www.bar.com

  ServerAlias bar.com *.bar.com

  DocumentRoot /var/www/bar

  <Directory /var/www/bar>

    <IfModule mod_access.c>

      Order allow,deny

      Allow from all

    </IfModule>

  </Directory>

</VirtualHost>

```

Where the IP address is the address for your server in your internal LAN.

Next I edited /opt/tomcat/conf/jk2.properties (you may have to create this file)

```

# jk2.properties

# Set the desired handler list

handler.list=channelSocket,request

# UNIX Domain socket location

channelSocket.port=8009

# Dynamic library

serverRoot=/usr/local/apache2

apr.NativeSo=/etc/apache2/extramodules/libjkjni.so

```

Next I rewrote /opt/tomcat/conf/server.xml

Note that what I wanted to do, was place all of the webapps into a /var/www/[domain]/webapp/ directory, but I want to declare each webapp individually.

```

<!-- Foo-Bar Server Configuration File -->

<Server port="8005" shutdown="SHUTDOWN" debug="0">

  <!-- Define the Tomcat-Apache Service -->

  <Service name="Tomcat-Apache">

    <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->

    <Connector className="org.apache.coyote.tomcat5.CoyoteConnector"

               port="8009" minProcessors="5" maxProcessors="30"

               enableLookups="true" redirectPort="8443" debug="0"

               acceptCount="10" connectionTimeout="20000"

               useURIValidationHack="false"

               protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" />

         

    <!-- Define the top level container in our container hierarchy -->

    <Engine name="Apache" defaultHost="www.foo.com" debug="0">

      <!-- Global logger unless overridden at lower levels -->

      <Logger className="org.apache.catalina.logger.FileLogger"

              prefix="apache_log." suffix=".txt"

              timestamp="true"/>

      <Valve className="org.apache.catalina.valves.AccessLogValve"

             directory="logs" prefix="localhost_access_log."

             suffix=".txt" pattern="common" resolveHosts="false" />

             

      <!-- Define foo.com virtual host -->

      <Host name="www.foo.com" debug="0"

            appBase="/var/www/foo/webapp"

            unpackWARs="true" autoDeploy="true" >

        <Alias>localhost</Alias>

        <Alias>foo.com</Alias>

        

        <Context path="/webapp/bob" docBase="bob" debug="0" />

        <Context path="/webapp/isYourUncle" docBase="isYourUncle" debug="0" />

      </Host>

      

      <!--Define bar.com virtual host -->

      <Host name="www.bar.com" debug="0"

            appBase="/var/www/bar/webapp"

            unpackWARs="true" autoDeploy="true" >

        <Alias>bar .com</Alias>

        

        <Context path="/webapp/rob" docBase="rob" debug="0" />

        <Context path="/webapp/roy" docBase="roy" debug="0" />

      </Host>

    </Engine>

  </Service>

</Server>

```

Then I edited /etc/apache2/conf/workers2.properties (you may have to create this file)

```

# workers2.properties

[shm]

file=anonymous

[channel.socket:localhost:8009]

port=8009

host=127.0.0.1

#

# Define the worker

#

[ajp13:localhost:8009]

channel=channel.socket:localhost:8009

#

# Uri Mappings

#

[uri:www.foo.com/webapp/bob/*]

worker=ajp13:localhost:8009

[uri:www.foo.com/webapp/isYourUncle/*]

worker=ajp13:localhost:8009

###

[uri:www.bar.com/webapp/rob/*]

worker=ajp13:localhost:8009

[uri:www.bar.com/webapp/roy/*]

worker=ajp13:localhost:8009

```

I copied my .war files (or expanded webapps) into the proper locations in /var/www, and I made sure that tomcat could read them...

```
chown -R tomcat:tomcat /var/www/[domain]/webapp/
```

Then I started up tomcat 

```
/etc/init.d/tomcat start
```

Note: After you start tomcat, wait a few seconds before starting apache2.  The author recommends singing Camp Town Races or Buffalo Gal.  "Won't you come out tonight, won't you come out tonight

Finally I started apache 

```
/etc/init.d/apache2 start
```

That did it for me, every thing works quite nicely!  My apologies if this doesn't work for you, or if you have other goals cause I probably won't be able to help you... but maybe this will get you on your way.

Thanks to all of the other posters, I couldn't have gotten it working without your great help!

----------

## MrStaticVoid

Wow...I had no idea this many people used Tomcat.  To me, JSP and Servelts are gifts from God.  They are fast and much more powerful than PHP.  I just wish more people would embrace it.

I noticed a lot of people are having problems with mod_jk2.  Now that I am using Tomcat 5, I have decided to switch to mod_jk2, rather than mod_jk, as mod_jk2 is supported out of the box.  At first I compiled it manually and set it up using http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jk2/jk2/confighowto.html .  It couldn't have been easier.  To me, a slightly slower setup with a vanilla configuration is better than one that is tangled by hundreds of configuration options.  That quick start guide was perfect.  Since then I have been using, supporting and contributing to the mod_jk2 ebuild in the Gentoo Bugzilla.  I hope that if more people use it, it will be put into Portage.  Portage needs more Java support.

So to all the people who are having problems:

Start over.  Use Tomcat 5 from Portage with a default server.xml.  Clear out any mod_jk/mod_jk2 configuration files and libraries.  Get the latest version of mod_jk2 and setup the most clean configuration files possible using the official Tomcat documentation.  You shouldn't have to touch server.xml.  If you don't want to touch any configuration files, just get use the ebulid in bugzilla.  If you do that, there is no reason why it wouldn't work.

----------

## etosh

I was able to get mod_jk2 connector working with tomcat 5.0.18  and apache2 using a slight variation from aent's post.  here's the steps I followed, most of which is based on aent's post: 

```
# wget http://apache.mirrors.pair.com/jakarta/tomcat-connectors/jk2/jakarta-tomcat-connectors-jk2-src-current.tar.gz

# tar -xvzf jakarta-tomcat-connectors-jk2-src-current.tar.gz

# mkdir /usr/build

# ln -s /usr/bin/libtool /usr/build/libtool

# cp /usr/lib/apache2/build/config_vars.mk /usr/build/

# cd jakarta-tomcat-connectors-jk2-*-src/jk/native2/

# chmod 0777 buildconf.sh

# ./buildconf.sh

# ./configure --with-apxs2=/usr/sbin/apxs2 --with-tomcat41=/opt/tomcat

# make clean build

# libtool --finish /usr/lib/apache2

# cp ../build/jk2/apache2/mod_jk2.so /etc/apache2/extramodules/
```

when I compiled the connector it never made a jkjni.so file for me, and it turns out I didn't need it.   I also had to make my own mod_jk.conf file from scratch, since I wasn't able to get it to auto-generate.  

here are the contents of some of my key files:

/etc/apache2/conf/workers2.properties

```
[logger]

level=DEBUG

[config:]

file=${serverRoot}/conf/workers2.properties

debug=0

debugEnv=0

[uriMap:]

info=Maps the requests. Options: debug

debug=0

# Alternate file logger

#[logger.file:0]

#level=DEBUG

#file=${serverRoot}/logs/jk2.log

[shm:]

info=Scoreboard. Required for reconfiguration and status with multiprocess servers

file=${serverRoot}/logs/jk2.shm

size=1000000

debug=0

disabled=0

[workerEnv:]

info=Global server options

timing=1

debug=0

# Default Native Logger (apache2 or win32 ) 

# can be overriden to a file logger, useful 

# when tracing win32 related issues

#logger=logger.file:0

[lb:lb]

info=Default load balancer.

debug=0

[lb:lb_1]

info=A second load balancer.

debug=0

[channel.socket:localhost:8009]

info=Ajp13 forwarding over socket

debug=0

tomcatId=localhost:8009

[channel.socket:localhost:8019]

info=A second tomcat instance. 

debug=0

tomcatId=localhost:8019

lb_factor=1

group=lb

group=lb_1

disabled=0

[channel.un:/opt/33/work/jk2.socket]

info=A second channel connecting to localhost:8019 via unix socket

tomcatId=localhost:8019

lb_factor=1

debug=0

[channel.jni:jni]

info=The jni channel, used if tomcat is started inprocess

[status:]

info=Status worker, displays runtime informations

[vm:]

info=Parameters used to load a JVM in the server process

#JVM=C:\jdk\jre\bin\hotspot\jvm.dll

classpath=${TOMCAT_HOME}/bin/tomcat-jni.jar

classpath=${TOMCAT_HOME}/server/lib/commons-logging.jar

OPT=-Dtomcat.home=${TOMCAT_HOME}

OPT=-Dcatalina.home=${TOMCAT_HOME}

OPT=-Xmx128M

#OPT=-Djava.compiler=NONE

disabled=1

[worker.jni:onStartup]

info=Command to be executed by the VM on startup. This one will start tomcat.

class=org/apache/jk/apr/TomcatStarter

#ARG=start

# For Tomcat 5 use the 'stard' for startup argument

ARG=stard

disabled=1

stdout=${serverRoot}/logs/stdout.log

stderr=${serverRoot}/logs/stderr.log

[worker.jni:onShutdown]

info=Command to be executed by the VM on shutdown. This one will stop tomcat.

class=org/apache/jk/apr/TomcatStarter

ARG=stop

disabled=1

[uri:/jkstatus/*]

info=Display status information and checks the config file for changes.

group=status:

[uri:/*.jsp]

info= use tomcat for all jsp pages

```

/etc/tomcat/jk2.properties

```
## THIS FILE MAY BE OVERRIDEN AT RUNTIME. MAKE SURE TOMCAT IS STOPED

## WHEN YOU EDIT THE FILE.

## COMMENTS WILL BE _LOST_

## DOCUMENTATION OF THE FORMAT IN JkMain javadoc.

# Set the desired handler list

# handler.list=apr,request,channelJni

#

# Override the default port for the socketChannel

# channelSocket.port=8019

# Default: 

# channelUnix.file=${jkHome}/work/jk2.socket

# Just to check if the the config  is working

# shm.file=${jkHome}/work/jk2.shm

# In order to enable jni use any channelJni directive

# channelJni.disabled = 0

# And one of the following directives:

# apr.jniModeSo=/opt/apache2/modules/mod_jk2.so

# If set to inprocess the mod_jk2 will Register natives itself

# This will enable the starting of the Tomcat from mod_jk2

# apr.jniModeSo=inprocess

# list of needed handlers.

handler.list=channelSocket,request

# Override the default port for the channelSocket

channelSocket.port=8009 
```

/etc/tomcat/server.xml

```
<Server port="8005" shutdown="SHUTDOWN">

  <GlobalNamingResources>

    <!-- Used by Manager webapp -->

    <Resource name="UserDatabase" auth="Container"

              type="org.apache.catalina.UserDatabase"

      description="User database that can be updated and saved">

    </Resource>

    <ResourceParams name="UserDatabase">

      <parameter> 

        <name>factory</name>

        <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>

      </parameter>

      <parameter>

        <name>pathname</name>

        <value>conf/tomcat-users.xml</value>

      </parameter>

    </ResourceParams>

  </GlobalNamingResources>

  <Service name="Catalina">

    <Connector port="8080" />

    <Engine name="Catalina" defaultHost="localhost">

      <Logger className="org.apache.catalina.logger.FileLogger" />

      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"

             resourceName="UserDatabase" />

      <Host name="localhost" appBase="webapps" />

    </Engine>

  </Service>

  

<Service name="Tomcat-Apache">

 

   <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->

    <Connector className="org.apache.coyote.tomcat5.CoyoteConnector" protocol="AJP/1.3"

               port="8009" minProcessors="5" maxProcessors="75"

               enableLookups="true" redirectPort="8443"

               acceptCount="10" debug="0" connectionTimeout="20000"

               useURIValidationHack="false"

               protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>

   <Engine name="Apache" defaultHost="localhost" debug="0">

   <Logger className="org.apache.catalina.logger.FileLogger" prefix="apache_log." suffix=".txt" timestamp="true"/>

   <!-- Access log processes all requests for this virtual host. -->

   <Valve className="org.apache.catalina.valves.AccessLogValve"

                 directory="logs"  prefix="localhost_access_log." suffix=".txt"

                 pattern="common" resolveHosts="false"/>

   <Host name="www.website.com" debug="0" appBase="/var/www/localhost/htdocs/website" unpackWARs="true" autoDeploy="true">

      <Alias>www</Alias>

      <Context path="" docBase="" debug="1"/>

  <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  prefix="home_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>

  </Host>

</Engine>

</Service>

      

  

</Server>
```

/etc/apache2/conf/modules.d/mod_jk.conf

```
<IfModule !mod_jk2.c>

   LoadModule jk2_module                        extramodules/mod_jk2.so

</IfModule>
```

----------

## phuber

Hi all

I'm currently trying to get mod_jk2 installed using the ebuild linked in this thread. I just noticed that the ebuild depends on tomcat5 yet I am using jboss-3.2

-> when I have jboss emerged the ebuild should not emerge tomcat, right?

Maybe someone wants to fix that, I'm no ebuild guru. But I'm able to remove the tomcat dependency  :Smile: 

----------

## Spice

Thank you very much!

I tried to compile and install the mod_jk2 by myself, but it fails every time.

With the ebuild file it was very simple to install. Thanks a lot!   :Laughing: 

But I've still one question: What is the workers2.properties file for?

What is the reson for mapping uris? I don't map any uri and can access every jsp file I build.

Thanks fpor your answer...

Spice

----------

## gcombe74

here is a snippet of to answer your question.

The config file is named "workers2.properties", located by default in ${serverRoot}/conf, where ${serverRoot} is the web server dir, like /usr/local/apache. It is possible to modify the location of the file using server-specific directives.

This link will driect you to all the info you can handle in what the workers.properties file is for.   I am not even sure I "get" it all.

http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jk2/jk2/configweb.html

----------

## barrct

Ok, I've tried mod_jk, mod_jk2, howtows from Tomcat, Apache, web, and of course this forum but I still can't everything running. I know that I've got Apache talking to Tomcat because I do not use beta.foo.com in apache so it does not resolve to anything, and when I kick Tomcat on beta.foo.com/test.jsp pulls right up. BUT None of the Java compiles or is interpreted at all.

```
<%@page language='java' contentType='text/html'%>

<html>

<head>

  <title>test</title>

</head>

<body>

<%="test"%>

</body>

</html>
```

And I can't even find where it says that it's loading that page in any of the Apache or Tomcat logs?

Any ideas?

----------

## barrct

I followed this guide.

http://www.reliablepenguin.com/clients/misc/tomcat/

And everything went in perfectly. Of course all of the paths are wrong, but you can find/locate/whatever the requested files.

Although after this and I could get to the correctl places though port 80, the jsp still does not compile and just outputs itself to the HTML page?

Anyone have an idea about this?

----------

## nilbus

Since the URL in the original post for mod_jk doesn't work anymore, here it is:

http://www.apache.org/dist/jakarta/tomcat-connectors/jk/

----------

## theansaname

Heres how I did it for Tomcat5 and mod_jk.  FYI mod_jk2 has been deprecated and longer being developed

recommend you -pv it first just to be sure

```

# su -

# emerge apache tomcat

# chown -R tomcat:tomcat /opt/tomcat5

```

testing the ebuild

```

# chmod 755 /etc/conf.d/tomcat5

# /etc/init.d/apache2 start

# /etc/init.d/tomcat start

```

use your browser and to see if you get the default pages

eg: 

http://localhost/

http://localhost:8080/

or 

http://you.ipa.ddr.ess/

http://you.ipa.ddr.ess:8080/

```

# /etc/init.d/apache2 stop

# /etc/init.d/tomcat5 stop

# rc-update add apache2 default && rc-update add tomcat5 default

```

Download mod_jk from http://jakarta.apache.org/site/downloads/downloads_tomcat-connectors.cgi

Get 1.2.x (1.2.8 as of this time) source release.  I prefer the zip.  backedup config_vars.mk just incase

I use vim for my editor

```

#cp /usr/lib/apache2/build/config_vars.mk /usr/lib/apache2/build/config_vars.mk.bak

#cd /var/tmp

#wget http://somemirror/bunchoffolders/jakarta-tomcat-connectors-current-src.zip

#unzip jakarta-tomcat-connectors-current-src.zip

#cd jakarta-tomcat-connectors-1.2.x-src/jk/

#native/buildconf.sh && native/configure --with-apxs=/usr/sbin/apxs2 && make

#cp native/apache-2.0/mod_jk.so /usr/lib/apache2/modules/

#vim /usr/lib/apache2/conf/workers.properties

```

file workers.properties.  Make sure you change your tomcat_home and java_home to your respective locations

you can page your profile.env if your unsure what the locations are (less /etc/profile.env)

```

workers.tomcat_home=/opt/tomcat5

workers.java_home=/opt/blackdown-jdk-1.4.2.01

ps=/

worker.list=default

worker.default.port=8009

worker.default.host=localhost

worker.default.type=ajp13

worker.default.lbfactor=1

```

httpd.conf is deprecated

```

#vim /ust/lib/apache2/conf/apache2.conf

```

add the following

```

LoadModule jk_module                   modules/mod_jk.so

###

### mod_jk

###

JkWorkersFile "conf/workers.properties"

JkLogFile "logs/mod_jk.log"

JkLogFile error

JkMount /* default

# End mod_jk

```

your basically done right now. But lets configure your tomcat first

```

#cd /opt/tomcat5/conf

#vi tomcat-users.xml

```

```

<?xml version='1.0' encoding='utf-8'?>

<tomcat-users>

  <role rolename="manager"/>

  <role rolename="admin"/>

  <user username="user" password="password" fullName="TheUser" roles="admin,manager"/>

</tomcat-users>

```

Start tomcat5 first, wait a couple of secs for the server to check its configs, start apache, exit wheel

```

#/etc/init.d/tomcat5 start && sleep 10 && /etc/init.d/apache2 start && exit

```

now test your mod_jk connection

point your browser to

Apache2 still working if default pages shows

http://you.ipa.ddr.ess

Tomcat5 still working if default pages shows

http://you.ipa.ddr.ess:8080

Tomcat5 still working if tomcat doc pages shows

http://you.ipa.ddr.ess:8080/tomcat-docs

mod_jk working if tomcat doc pages shows

http://you.ipa.ddr.ess/tomcat-docs

by defaults all your http files are stored in /var/www/localhost/htdocs

and tomcat files(jsp,sevlets) in /opt/tomcat5/webapps/

so you might not want to have apache default everything to tomcat 

in /usr/lib/apache2/conf/apache2.conf

```

###

### mod_jk

###

JkWorkersFile "conf/workers.properties"

JkLogFile "logs/mod_jk.log"

JkLogFile error

##

##folders to mount

##

#JkMount /* default

JkMount /myjsps default

JkMount /myjsps/* default

# End mod_jk

```

or just have .jsp files be processed by tomcat

```

JkMount /myjsps/*.jsp default

```

```

# /etc/init.d/apache2 restart

```

Sources aside from this post

 *Quote:*   

> 
> 
> http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/rzaie/rzaiemod_jk.htm#jkasftomcat
> 
> http://www.galatea.com/flashguides/apache20-tomcat5-modjk-linux
> ...

 

----------

## newtonian

Thanks for posting the tutorial.

It saved me a lot of time.  Everything is working well on my system except log output but

I'll mess with that someother time.

Going through your tutorial I came across a problem.

 *Quote:*   

> 
> 
> cd jakarta-tomcat-connectors-1.2.x-src/jk/
> 
> #native/buildconf.sh && native/configure --with-apxs=/usr/sbin/apxs2 && make 
> ...

 

pasting this code into my terminal window and running it caused the following error:

```

hawk jk # native/buildconf.sh

rm autom4te.cache

libtoolize --force --automake --copy

libtoolize: `configure.ac' does not exist

Try `libtoolize --help' for more information.

aclocal

aclocal-1.9: `configure.ac' or `configure.in' is required

autoheader

autoheader-2.59: `configure.ac' or `configure.in' is required

automake -a --foreign --copy

automake-1.9: `configure.ac' or `configure.in' is required

autoconf

autoconf-2.59: no input file

rm autom4te.cache

```

To get around the problem I did 

```

cd native/

./buildconf.sh

./configure --with-apxs=/usr/sbin/apxs2

make

```

and everything worked fine.

I ran the command as root with the following path:

```

hawk native # echo $PATH

/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/opt/bin:/usr/i686-pc-lin

ux-gnu/gcc-bin/3.3.5:/usr/X11R6/bin:/opt/sun-jdk-1.4.2.07/bin:/op

t/sun-jdk-1.4.2.07/jre/bin:/opt/sun-jdk-1.4.2.07/jre/javaws:/usr/qt/3

/bin:/usr/kde/3.3/sbin:/usr/kde/3.3/bin:/var/qmail/bin:/var/vpopmail/bin

```

Do you think my path caused it to not execute correctly?

other than that, changing:

```

#vim /ust/lib/apache2/conf/apache2.conf 

```

to 

```

vim /usr/lib/apache2/conf/httpd.conf

```

might score some points with fellow vimmers.

Cheers,Last edited by newtonian on Fri Nov 18, 2005 9:04 pm; edited 1 time in total

----------

## kamina

 *theansaname wrote:*   

> 
> 
> ```
> 
> #vim /usr/lib/apache2/conf/workers.properties
> ...

 

I don't have that file there... Should I make a copy from the folder where I downloaded the sources, or have I messed up at an earlier point?

After trying to follow the instructions I can still open up localhost:8080, but not localhost or the tomcat-docs.

----------

## newtonian

 *kamina wrote:*   

>  *theansaname wrote:*   
> 
> ```
> 
> #vim /usr/lib/apache2/conf/workers.properties
> ...

 

I made workers.properties by myself.  I think that's how it's usually done.  

Did you emerge tomcat? or download the binary? 

What version are you running? 5.0.27-r4 or 5.0.28?

What command did you use to start tomcat? /etc/init.d/?????

What is the output of logs/catatina.out after startup?

Cheers,

----------

## kamina

I did slocate to find a file with that name, and found it in jk sources. Tomcat version is 5.0.27-r4, I noticed some people having problems with 5.0.28 so decided not to install it yet. I installed by emerging. Tomcat was started normally with "/etc/init.d/tomcat5 start".

```

Mar 11, 2005 6:23:59 PM org.apache.coyote.http11.Http11Protocol init

INFO: Initializing Coyote HTTP/1.1 on http-8080

Mar 11, 2005 6:23:59 PM org.apache.catalina.startup.Catalina load

INFO: Initialization processed in 5327 ms

Mar 11, 2005 6:24:00 PM org.apache.catalina.core.StandardService start

INFO: Starting service Catalina

Mar 11, 2005 6:24:00 PM org.apache.catalina.core.StandardEngine start

INFO: Starting Servlet Engine: Apache Tomcat/5.0.27

Mar 11, 2005 6:24:00 PM org.apache.catalina.core.StandardHost start

INFO: XML validation disabled

Mar 11, 2005 6:24:00 PM org.apache.catalina.core.StandardHost getDeployer

INFO: Create Host deployer for direct deployment ( non-jmx )

Mar 11, 2005 6:24:00 PM org.apache.catalina.core.StandardHostDeployer install

INFO: Processing Context configuration file URL file:/etc/tomcat5/Catalina/localhost/manager.xml

Mar 11, 2005 6:24:03 PM org.apache.catalina.core.StandardHostDeployer install

INFO: Processing Context configuration file URL file:/etc/tomcat5/Catalina/localhost/admin.xml

Mar 11, 2005 6:24:04 PM org.apache.struts.util.PropertyMessageResources <init>

INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true

Mar 11, 2005 6:24:04 PM org.apache.struts.util.PropertyMessageResources <init>

INFO: Initializing, config='org.apache.struts.action.ActionResources', returnNull=true

Mar 11, 2005 6:24:06 PM org.apache.struts.util.PropertyMessageResources <init>

INFO: Initializing, config='org.apache.webapp.admin.ApplicationResources', returnNull=true

Mar 11, 2005 6:24:12 PM org.apache.catalina.core.StandardHostDeployer install

INFO: Processing Context configuration file URL file:/etc/tomcat5/Catalina/localhost/balancer.xml

Mar 11, 2005 6:24:13 PM org.apache.catalina.core.StandardHostDeployer install

INFO: Installing web application at context path  from URL file:/opt/tomcat5/webapps/ROOT

Mar 11, 2005 6:24:14 PM org.apache.catalina.core.StandardHostDeployer install

INFO: Installing web application at context path /webdav from URL file:/opt/tomcat5/webapps/webdav

Mar 11, 2005 6:24:15 PM org.apache.coyote.http11.Http11Protocol start

INFO: Starting Coyote HTTP/1.1 on http-8080

Mar 11, 2005 6:24:15 PM org.apache.jk.common.ChannelSocket init

INFO: JK2: ajp13 listening on /0.0.0.0:8009

Mar 11, 2005 6:24:15 PM org.apache.jk.server.JkMain start

INFO: Jk running ID=0 time=9/154  config=/opt/tomcat5/conf/jk2.properties

Mar 11, 2005 6:24:16 PM org.apache.catalina.startup.Catalina start

INFO: Server startup in 16388 ms

```

----------

## newtonian

 *Quote:*   

> After trying to follow the instructions I can still open up localhost:8080

 

This means tomcat is running fine.

 *Quote:*   

> , but not localhost 

 

So when you type http://localhost you don't get anything?  Not even the welcome to apache page?

 *Quote:*   

> or the tomcat-docs.

 

I don't think the docs are installed with the "emerge tomcat" command.  

run:

```

find /opt/tomcat5 -iname 'tomcat-docs'

```

if nothing comes up then maybe you don't have the docs installed in your machine.

 *kamina wrote:*   

> I did slocate to find a file with that name, and found it in jk sources.

 

If you use workers.properties that came with the src file as is, with the apache setup above, it will NOT work.  Make your own workers.properties with the information listed above.

 *Quote:*   

> Tomcat version is 5.0.27-r4, I noticed some people having problems with 5.0.28 so decided not to install it yet.

 

good idea

 *Quote:*   

> I installed by emerging. Tomcat was started normally with "/etc/init.d/tomcat5 start".

 

sounds good

You're catalina.out log looks fine.

what command do you use to start apache?

----------

## kamina

I finally (think) I have it working correctly, but now I need some real newbie help.

I have a project I was developing on another server, and I would like to continue on my own one. I moved the folder under webapps, but don't know how I could configure it so that I will reach the project with either http://my.ip or http://my.ip:8080 . On the server i was developing it, everything (including images and http files went under the same directory, and then there was a subdirectory WEB-INF/classes for java classes. I did'nt quite figure out how I will get apache to forward everything to tomcat, and if I need to have the html files under apaches directory?  :Very Happy: 

edit:

Also, my tomcat-users.xml looks like this:

```

<?xml version='1.0' encoding='utf-8'?>

<tomcat-users>

  <role rolename="tomcat"/>

  <role rolename="role1"/>

  <user username="tomcat" password="tomcat" roles="tomcat"/>

  <user username="role1" password="tomcat" roles="role1"/>

  <user username="both" password="tomcat" roles="tomcat,role1"/>

</tomcat-users>

```

Should I add the info mentioned above to this, or remove all the default values?

----------

## newtonian

 *Quote:*   

> 
> 
> don't know how I could configure it so that I will reach the project with either http://my.ip or http://my.ip:8080
> 
> 

 

delete the contents of the $CATALINA_HOME/webapps/ROOT directory.  

Move the contents of $CATALINA_HOME/webapps/ myWebAppFolder to $CATALINA_HOME/webapps/ROOT

if going to http://my.ip, do this:  

     Turn apache off and change 8080 to 80 in conf/server.xml

      start tomcat

      browse to http://my.ip

if going to http://my.ip:8080

    Don't change server.xml, just leave it the way it is.

     start tomcat

     browse to http://my.ip:8080

In ethier case you don't use mod_jk or apache. 

 *Quote:*   

> 
> 
> On the server i was developing it, everything (including images and http files went under the same directory, 
> 
> and then there was a subdirectory WEB-INF/classes for java classes
> ...

 

Your setup will work fine with the instructions above.

Cheers,

----------

## kamina

Oh dear... So what did I install mod_jk2 for?  :Laughing: 

----------

## newtonian

 *kamina wrote:*   

> Oh dear... So what did I install mod_jk2 for? 

 

mod_jk2 allows you to use apache.   :Wink: 

Apache is nice to use because it is much faster than Tomcat.

Apache makes it easy to do php.  

Apache, mod_jk2, and the php mod makes it easy to have PHP only sites and JSP only sites co-exists on the same system.

I use the apache/mod_jk/tomcat mix over a tomcat only solution because:

1. I use phpmyadmin

2. I have several tomcat versions running on the same machine for many different virtual hosts.  Apache acts as a proxy for all of the different websites located on my gentoo box.

If you have modern hardware, no need for php and only 1 domain then I'd recommend staying with a single tomcat no apache setup.  It's simple, and much easier to debug.

If you decide that you need the extra functionality that apache and mod_jk provide, let me know and I'll try to point you in the right direction.

----------

## kamina

Thanks alot. This is a fairly old machine (p3 600, 768mb ram) and is more of a hobby. I have alot of java courses in university so I prefere to play around with that rather then php (even though php would do what I want easier). Just trying to gather some experience. The box will hopefully end up with a small service with drink recipes (servlets) and a very basic "forum" (jsp). So I guess I can forget about apache and mod_jk then!  :Very Happy: 

----------

## newtonian

 *kamina wrote:*   

>  The box will hopefully end up with a small service
> 
>  with drink recipes (servlets) and a very basic "forum" (jsp). 

 

Building a java forum yourself might be fun.  If you don't want to start 

from scratch, you can check out the java open source forum software at:

http://java-source.net/open-source/forum-software

Jforum is almost identical to the phpBB(this forum) on the outside but is all java on the inside.

 *Quote:*   

> So I guess I can forget about apache and mod_jk then! 

 

Believe me, there is plenty to learn with java, tomcat, struts, slides, velocity, jsf, 

hibernate, xml, xsl, eclipse, netbeans, junit, ant, EJB, jndi, soap ... you get the point.  

No need to make things any more complicated than you have to.

Cheers,

----------

## kamina

A million thanks for the help. I'm trying to finish my recipe "service" with servlets now, and the forum will be my introduction to JSP. I prefere to do it all my self, as I don't have any need for advanced features. This will also help me get some more experience with software designing and documentation.

I changed all entries with 8080 in server.xml to 80, but now the server does'nt respond to either port... I did'nt do any other changes! (apache is not on, but I tested turning apache on and it started and awnsered just fine)

edit:

this looks like it might have something to do with the problem... from /var/log/tomcat5/catalina.out

```

SEVERE: Error starting endpoint

java.net.BindException: Permission denied:80

        at org.apache.tomcat.util.net.PoolTcpEndpoint.initEndpoint(PoolTcpEndpoint.java:264)

        at org.apache.tomcat.util.net.PoolTcpEndpoint.startEndpoint(PoolTcpEndpoint.java:281)

        at org.apache.coyote.http11.Http11Protocol.start(Http11Protocol.java:171)

        at org.apache.coyote.tomcat5.CoyoteConnector.start(CoyoteConnector.java:1527)

        at org.apache.catalina.core.StandardService.start(StandardService.java:489)

        at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)

        at org.apache.catalina.startup.Catalina.start(Catalina.java:556)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:324)

        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)

        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)

Mar 16, 2005 7:04:04 PM org.apache.catalina.startup.Catalina start

SEVERE: Catalina.start:

LifecycleException:  Protocol handler start failed: java.net.BindException: Permission denied:80

        at org.apache.coyote.tomcat5.CoyoteConnector.start(CoyoteConnector.java:1529)

        at org.apache.catalina.core.StandardService.start(StandardService.java:489)

        at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)

        at org.apache.catalina.startup.Catalina.start(Catalina.java:556)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:324)

        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)

        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)

Mar 16, 2005 7:04:04 PM org.apache.catalina.startup.Catalina start

```

edit2

Google helped a bit... I can't run on port 80 without root privaliges? What would be the gracefull way to take care of this? Make a "software proxy" that would redirect port 80 to 8080?

----------

## newtonian

Here's something I found on jguru :

 *Quote:*   

> 
> 
> Configuring tomcat to run on port 80, that is the default port for web (HTTP)service, you can just specify the hostname in the url address of your browser.
> 
> To configure in tomcat the port you have to modify conf/server.xml in the <Connector> tag as follows:
> ...

 

I thought the last line was interesting.  Did you try running it as root?

Cheers,

----------

## johnl

Hi all, I have read a lot of great info in this thread.  I have what seems to be a straighforward need, but I have not yet been able to accomplish it yet.  I am running Apache 2.0.52, Tomcat 5.0.28, and mod_jk2.  I apologize that this is on a Windows system (Server 2003), but it seems this thread has the most knowledge for me to tap!  Everything seems to be running fine, but I want to be able to hide, mask, map, whatever, the URL to the jsp pages.  Here is my workers2.properties file:

```

[shm]

info=Scoreboard. Requried for reconfiguration and status with multiprocess servers.

file=anon

# Defines a load balancer named lb. Use even if you only have one machine.

[lb:lb]

# Example socket channel, override port and host.

[channel.socket:localhost:8009]

port=8009

host=127.0.0.1

# define the worker

[ajp13:localhost:8009]

channel=channel.socket:localhost:8009

group=lb

# Map the Tomcat webapp to the Web server uri space

[uri:/appname/*]

group=lb

[status:]

info=Status worker, displays runtime information

[uri:/jkstatus/*]

info=The Tomcat /jkstatus handler

group=status:

```

I setup an alias in the httpd.conf file:

```

Alias /standalone/ "D:/Program Files/Apache Group/Tomcat5.0.28/webapps/appname/jsp/usr/standalone/"

<Directory "D:/Program Files/Apache Group/Tomcat5.0.28/webapps/appname/jsp/usr/standalone">

    Options Indexes MultiViews

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>

```

So, if I enter http: //ipaddress/appname/jsp/usr/standalone/file.jsp, the file loads and is properly passed to Tomcat.

If I enter http: //ipaddress/standalone/file.jsp, the file loads but is not passed to Tomcat.  

I don't want my users seeing the long, ugly URL.  What is the best/easiest way to accomplish this?  Any help is greatly appreciated!

John

----------

## Chipski

 *kamina wrote:*   

> 
> 
> ```
> 
> SEVERE: Error starting endpoint
> ...

 

Correct, and running externally available services as root isn't something I like doing, but all is not lost: use the following Netfilter "recipe" to redirect tcp requests to port 80 to 8080:

```
/sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
```

Which will send TCP packets arriving on interface eth0 (change as required) to port 8080 on the same machine. There's no problem opening ports > 1024 as an unprivileged user.

Note that this isn't the same as an HTTP redirect as nothing is sent back to the requester, the original matching packet is magically forwarded to the designated port on the same server. Not only that but you won't have to change tomcat's server.xml either; it still listens on the default 8080 running as an unprivileged account (which for extra security you could/should also set up to not be able to log on either, by changing the account's shell to /bin/false ).

Good luck with the studies.

----------

## zendmaster

I'm getting a make error.  Maybe one of you can identify my problem.

de/apache2 -g -O2 -O2 -mcpu=athlon -fomit-frame-pointer -pthread -DHAVE_APR  -I/var/tmp/portage/apache-2.0.52-r1/work/httpd-2.0.52/srclib/apr/include -g -O2 -DLINUX=2 -D_REENTRANT -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -I /opt/sun-jdk-1.4.2.07/include -I /opt/sun-jdk-1.4.2.07/include/ -c ../native/common/jk_status.c

make[1]: Leaving directory `/var/tmp/jakarta-tomcat-connectors-1.2.10-src/jk/common'

Making all in apache-2.0

make[1]: Entering directory `/var/tmp/jakarta-tomcat-connectors-1.2.10-src/jk/apache-2.0'

Makefile:33: ../scripts/build/rules.mk: No such file or directory

make[1]: *** No rule to make target `../scripts/build/rules.mk'.  Stop.

make[1]: Leaving directory `/var/tmp/jakarta-tomcat-connectors-1.2.10-src/jk/apache-2.0'

make: *** [all-recursive] Error 1

Thanks

----------

## newtonian

I got a problem when I tried to make jk_mount.  The compile 

stopped because make couldn't find a libtool. 

Here's what I did to fix it:

missing /usr/lib/apache2/build/libtool

to solve that, all you have to do is:

ln -s /usr/bin/libtool /usr/lib/apache2/build/libtool

Cheers,

----------

## songniao

i have following what you say.

after i configure&&make,i can not find mod_jk.so in ./apache-2.0 directory.why?

----------

## newtonian

 *songniao wrote:*   

> i have following what you say.
> 
> after i configure&&make,i can not find mod_jk.so in ./apache-2.0 directory.why?

 

1. maybe your compiled failed.  How about posting the output of your compile.

2. maybe if was put somewhere else, why not run 

```
updatedb
```

as root, then 

```
locate mod_jk.so
```

Cheers,

----------

## songniao

thanks !

i follow what you say.and configure and make,but can not find mod_jk.so too,here is the result of "make":

[color=red]Making all in common

make[1]: Entering directory `/root/jakarta-tomcat-connectors-1.2.15-src/jk/native/common'

make[1]: Nothing to be done for `all'.

make[1]: Leaving directory `/root/jakarta-tomcat-connectors-1.2.15-src/jk/native/common'

and if try to use "emerge mod_jk",this time get the error:

>>> Install mod_jk-1.2.13 into /var/tmp/portage/mod_jk-1.2.13/image/ category www-apache

install: cannot stat `/var/tmp/portage/mod_jk-1.2.13/work/jakarta-tomcat-connectors-1.2.13-src/jk/native/apache-2.0/mod_jk.so': No such file or directory

!!! ERROR: www-apache/mod_jk-1.2.13 failed.

!!! Function apache2_src_install, Line 290, Exitcode 1

!!! internal ebuild error: '/var/tmp/portage/mod_jk-1.2.13/work/jakarta-tomcat-connectors-1.2.13-src/jk/native/apache-2.0/mod_jk.so' not found

!!! If you need support, post the topmost build error, NOT this status message.[/color]

----------

## newtonian

I downloaded mod_jk and ran buildconf.sh, configured and ran make.

You might to do what I did and compare your results with mine.

 *Quote:*   

> 
> 
> hawk native # ./buildconf.sh 
> 
> rm autom4te.cache
> ...

 

then configure:

 *Quote:*   

> 
> 
> hawk native # ./configure --with-apxs=/usr/sbin/apxs2
> 
> checking build system type... i686-pc-linux-gnu
> ...

 

work around make error:

```
hawk native # ln -s /usr/bin/libtool /usr/lib/apache2/build/libtool
```

then

 *Quote:*   

> 
> 
> hawk native # make
> 
> Making all in common
> ...

 

----------

## songniao

thanks a lot.

code:

native # ./buildconf.sh

rm autom4te.cache

libtoolize --force --automake --copy

aclocal

/usr/share/aclocal/vorbis.m4:9: warning: underquoted definition of XIPH_PATH_VORBIS

  run info '(automake)Extending aclocal'

  or see http://sources.redhat.com/automake/automake.html#Extending%20aclocal

/usr/share/aclocal/pkg.m4:5: warning: underquoted definition of PKG_CHECK_MODULES

/usr/share/aclocal/ogg.m4:8: warning: underquoted definition of XIPH_PATH_OGG

/usr/share/aclocal/libmcrypt.m4:17: warning: underquoted definition of AM_PATH_LIBMCRYPT

/usr/share/aclocal/gtk.m4:7: warning: underquoted definition of AM_PATH_GTK

/usr/share/aclocal/glib.m4:8: warning: underquoted definition of AM_PATH_GLIB

/usr/share/aclocal/freetype2.m4:7: warning: underquoted definition of AC_CHECK_FT2

/usr/share/aclocal/audiofile.m4:12: warning: underquoted definition of AM_PATH_AUDIOFILE

autoheader

automake -a --foreign --copy

autoconf

rm autom4te.cache

code:

native # ./configure --with-apxs=/usr/sbin/apxs2 

checking build system type... i686-pc-linux-gnu

checking host system type... i686-pc-linux-gnu

checking target system type... i686-pc-linux-gnu

checking for a BSD-compatible install... /bin/install -c

checking whether build environment is sane... 

yes

checking for gawk... gawk

checking whether make sets $(MAKE)... yes

checking for gcc... gcc

checking for C compiler default output file name... a.out

checking whether the C compiler works... yes

checking whether we are cross compiling... no

checking for suffix of executables... 

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ANSI C... none needed

checking for style of include used by make... GNU

checking dependency style of gcc... none

checking for ld used by GCC... /usr/i686-pc-linux-gnu/bin/ld

checking if the linker (/usr/i686-pc-linux-gnu/bin/ld) is GNU ld... yes

checking for /usr/i686-pc-linux-gnu/bin/ld option to reload object files... -r

checking for BSD-compatible nm... /usr/bin/nm -B

checking for a sed that does not truncate output... /bin/sed

checking whether ln -s works... yes

checking how to recognise dependent libraries... pass_all

checking command to parse /usr/bin/nm -B output... ok

checking how to run the C preprocessor... gcc -E

checking for egrep... grep -E

checking for ANSI C header files... yes

checking for sys/types.h... yes

checking for sys/stat.h... yes

checking for stdlib.h... yes

checking for string.h... yes

checking for memory.h... yes

checking for strings.h... yes

checking for inttypes.h... yes

checking for stdint.h... yes

checking for unistd.h... yes

checking dlfcn.h usability... yes

checking dlfcn.h presence... yes

checking for dlfcn.h... yes

checking for ranlib... ranlib

checking for strip... strip

checking for objdir... .libs

checking for gcc option to produce PIC... -fPIC

checking if gcc PIC flag -fPIC works... yes

checking if gcc static flag -static works... yes

checking if gcc supports -c -o file.o... yes

checking if gcc supports -c -o file.lo... yes

checking if gcc supports -fno-rtti -fno-exceptions... no

checking whether the linker (/usr/i686-pc-linux-gnu/bin/ld) supports shared libraries... yes

checking how to hardcode library paths into programs... immediate

checking whether stripping libraries is possible... yes

checking dynamic linker characteristics... GNU/Linux ld.so

checking if libtool supports shared libraries... yes

checking whether to build shared libraries... yes

checking whether to build static libraries... yes

checking whether -lc should be explicitly linked in... no

creating libtool

checking for test... /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.3:/usr/X11R6/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin:/usr/qt/3/bin:/opt/tomcat5/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin

checking for rm... /bin/rm

checking for grep... /bin/grep

checking for echo... /bin/echo

checking for sed... /bin/sed

checking for cp... /bin/cp

checking for mkdir... /bin/mkdir

checking for uint32_t... yes

checking size of uint32_t... 4

checking for u_int32_t... yes

checking size of u_int32_t... 4

checking for unsigned long... yes

checking size of unsigned long... 4

checking for unsigned int... yes

checking size of unsigned int... 4

checking for unsigned long long... yes

checking size of unsigned long long... 8

checking for unsigned longlong... no

checking size of unsigned longlong... 0

checking for snprintf... yes

checking for vsnprintf... yes

checking for flock... yes

checking for setsockopt in -lsocket... no

checking whether to use SO_RCVTIMEO with setsockopt()... yes

checking whether to use SO_SNDTIMEO with setsockopt()... yes

./configure: line 11515: /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.3:/usr/X11R6/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin:/usr/qt/3/bin:/opt/tomcat5/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin: No such file or directory

checking for target platform... unix

no apache given

./configure: line 11836: /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.3:/usr/X11R6/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin:/usr/qt/3/bin:/opt/tomcat5/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin: No such file or directory

./configure: line 11839: /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.3:/usr/X11R6/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin:/usr/qt/3/bin:/opt/tomcat5/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin: No such file or directory

./configure: line 11846: /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.3:/usr/X11R6/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin:/usr/qt/3/bin:/opt/tomcat5/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin: No such file or directory

./configure: line 12041: /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.3:/usr/X11R6/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin:/usr/qt/3/bin:/opt/tomcat5/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin: No such file or directory

./configure: line 12053: /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.3:/usr/X11R6/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin:/usr/qt/3/bin:/opt/tomcat5/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin: No such file or directory

./configure: line 12062: /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.3:/usr/X11R6/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin:/usr/qt/3/bin:/opt/tomcat5/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin: No such file or directory

configure: creating ./config.status

config.status: creating Makefile

config.status: creating apache-1.3/Makefile

config.status: creating apache-1.3/Makefile.apxs

config.status: creating apache-2.0/Makefile

config.status: creating apache-2.0/Makefile.apxs

config.status: creating common/Makefile

config.status: creating common/list.mk

config.status: creating jni/Makefile

config.status: creating common/portable.h

config.status: common/portable.h is unchanged

config.status: executing depfiles commands

code:

 native # make

Making all in common

make[1]: Entering directory `/root/jakarta-tomcat-connectors-1.2.15-src/jk/native/common'

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp12_worker.c -o jk_ajp12_worker.lo

rm -f .libs/jk_ajp12_worker.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp12_worker.c  -fPIC -DPIC -o .libs/jk_ajp12_worker.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp12_worker.c -o jk_ajp12_worker.o >/dev/null 2>&1

mv -f .libs/jk_ajp12_worker.lo jk_ajp12_worker.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_connect.c -o jk_connect.lo

rm -f .libs/jk_connect.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_connect.c  -fPIC -DPIC -o .libs/jk_connect.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_connect.c -o jk_connect.o >/dev/null 2>&1

mv -f .libs/jk_connect.lo jk_connect.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_msg_buff.c -o jk_msg_buff.lo

rm -f .libs/jk_msg_buff.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_msg_buff.c  -fPIC -DPIC -o .libs/jk_msg_buff.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_msg_buff.c -o jk_msg_buff.o >/dev/null 2>&1

mv -f .libs/jk_msg_buff.lo jk_msg_buff.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_util.c -o jk_util.lo

rm -f .libs/jk_util.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_util.c  -fPIC -DPIC -o .libs/jk_util.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_util.c -o jk_util.o >/dev/null 2>&1

mv -f .libs/jk_util.lo jk_util.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp13.c -o jk_ajp13.lo

rm -f .libs/jk_ajp13.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp13.c  -fPIC -DPIC -o .libs/jk_ajp13.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp13.c -o jk_ajp13.o >/dev/null 2>&1

mv -f .libs/jk_ajp13.lo jk_ajp13.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_pool.c -o jk_pool.lo

rm -f .libs/jk_pool.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_pool.c  -fPIC -DPIC -o .libs/jk_pool.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_pool.c -o jk_pool.o >/dev/null 2>&1

mv -f .libs/jk_pool.lo jk_pool.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_worker.c -o jk_worker.lo

rm -f .libs/jk_worker.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_worker.c  -fPIC -DPIC -o .libs/jk_worker.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_worker.c -o jk_worker.o >/dev/null 2>&1

mv -f .libs/jk_worker.lo jk_worker.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp13_worker.c -o jk_ajp13_worker.lo

rm -f .libs/jk_ajp13_worker.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp13_worker.c  -fPIC -DPIC -o .libs/jk_ajp13_worker.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp13_worker.c -o jk_ajp13_worker.o >/dev/null 2>&1

mv -f .libs/jk_ajp13_worker.lo jk_ajp13_worker.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_lb_worker.c -o jk_lb_worker.lo

rm -f .libs/jk_lb_worker.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_lb_worker.c  -fPIC -DPIC -o .libs/jk_lb_worker.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_lb_worker.c -o jk_lb_worker.o >/dev/null 2>&1

mv -f .libs/jk_lb_worker.lo jk_lb_worker.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_sockbuf.c -o jk_sockbuf.lo

rm -f .libs/jk_sockbuf.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_sockbuf.c  -fPIC -DPIC -o .libs/jk_sockbuf.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_sockbuf.c -o jk_sockbuf.o >/dev/null 2>&1

mv -f .libs/jk_sockbuf.lo jk_sockbuf.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_map.c -o jk_map.lo

rm -f .libs/jk_map.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_map.c  -fPIC -DPIC -o .libs/jk_map.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_map.c -o jk_map.o >/dev/null 2>&1

mv -f .libs/jk_map.lo jk_map.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_uri_worker_map.c -o jk_uri_worker_map.lo

rm -f .libs/jk_uri_worker_map.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_uri_worker_map.c  -fPIC -DPIC -o .libs/jk_uri_worker_map.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_uri_worker_map.c -o jk_uri_worker_map.o >/dev/null 2>&1

mv -f .libs/jk_uri_worker_map.lo jk_uri_worker_map.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp14.c -o jk_ajp14.lo

rm -f .libs/jk_ajp14.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp14.c  -fPIC -DPIC -o .libs/jk_ajp14.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp14.c -o jk_ajp14.o >/dev/null 2>&1

mv -f .libs/jk_ajp14.lo jk_ajp14.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp14_worker.c -o jk_ajp14_worker.lo

rm -f .libs/jk_ajp14_worker.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp14_worker.c  -fPIC -DPIC -o .libs/jk_ajp14_worker.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp14_worker.c -o jk_ajp14_worker.o >/dev/null 2>&1

mv -f .libs/jk_ajp14_worker.lo jk_ajp14_worker.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_md5.c -o jk_md5.lo

rm -f .libs/jk_md5.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_md5.c  -fPIC -DPIC -o .libs/jk_md5.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_md5.c -o jk_md5.o >/dev/null 2>&1

mv -f .libs/jk_md5.lo jk_md5.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_shm.c -o jk_shm.lo

rm -f .libs/jk_shm.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_shm.c  -fPIC -DPIC -o .libs/jk_shm.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_shm.c -o jk_shm.o >/dev/null 2>&1

mv -f .libs/jk_shm.lo jk_shm.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp_common.c -o jk_ajp_common.lo

rm -f .libs/jk_ajp_common.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp_common.c  -fPIC -DPIC -o .libs/jk_ajp_common.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_ajp_common.c -o jk_ajp_common.o >/dev/null 2>&1

mv -f .libs/jk_ajp_common.lo jk_ajp_common.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_context.c -o jk_context.lo

rm -f .libs/jk_context.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_context.c  -fPIC -DPIC -o .libs/jk_context.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_context.c -o jk_context.o >/dev/null 2>&1

mv -f .libs/jk_context.lo jk_context.lo

/bin/sh ../libtool --mode=compile gcc -g -O2   -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_status.c -o jk_status.lo

rm -f .libs/jk_status.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_status.c  -fPIC -DPIC -o .libs/jk_status.lo

gcc -g -O2 -I /opt/blackdown-jdk-1.4.1/include -I /opt/blackdown-jdk-1.4.1/include/ -c jk_status.c -o jk_status.o >/dev/null 2>&1

mv -f .libs/jk_status.lo jk_status.lo

make[1]: Leaving directory `/root/jakarta-tomcat-connectors-1.2.15-src/jk/native/common'

make[1]: Entering directory `/root/jakarta-tomcat-connectors-1.2.15-src/jk/native'

make[1]: Nothing to be done for `all-am'.

make[1]: Leaving directory `/root/jakarta-tomcat-connectors-1.2.15-src/jk/native'

target="all"; \

list='common '; \

for i in $list; do \

    echo "Making $target in $i"; \

    if test "$i" != "."; then \

       (cd $i && make $target) || exit 1; \

    fi; \

done;

Making all in common

make[1]: Entering directory `/root/jakarta-tomcat-connectors-1.2.15-src/jk/native/common'

make[1]: Nothing to be done for `all'.

make[1]: Leaving directory `/root/jakarta-tomcat-connectors-1.2.15-src/jk/native/common'

----------

## songniao

and i use

native # ls ./apache-2.0

Makefile       Makefile.apxs.in  Makefile.vc    bldjk.qclsrc  mod_jk.c

Makefile.apxs  Makefile.in       NWGNUmakefile  config.m4     mod_jk.dsp

can not see any ".so" files

----------

## newtonian

 *songniao wrote:*   

> 
> 
> creating libtool
> 
> checking for test... /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.3:/usr/X11R6/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin:/usr/qt/3/bin:/opt/tomcat5/bin:/opt/blackdown-jdk-1.4.1/bin:/opt/blackdown-jdk-1.4.1/jre/bin
> ...

 

I think it's having trouble finding some important files.  Try this and post your results:

 *Quote:*   

> hawk david # which test
> 
> /usr/bin/test
> 
> hawk david # emerge search coreutils
> ...

 

Cheers,

----------

## songniao

oh yes.

i have rename the /usr/bin/test to /usr/bin/test1

now i rechange to /usr/bin/test

and the problem is solved.thanks a lot

i will continute to install ....

----------

## newtonian

 *songniao wrote:*   

> oh yes.
> 
> i have rename the /usr/bin/test to /usr/bin/test1
> 
> now i rechange to /usr/bin/test
> ...

 

Cool,    :Very Happy: 

Cheers,

----------

## newtonian

This topic covers a lot of info on how to build the latest version of mod_jk, but if you'd rather 

just emerge it, be sure to check out the wiki:

http://gentoo-wiki.com/HOWTO_Apache2_and_Tomcat5

Cheers,

----------

## songniao

yes.i have follown what you say.and i "emerge mod_jk",it sound OK.

i user http://myIP/index.html  ---------------is OK

and use http://myIP:8080/index.html     ------------------is OK

and i write a jsp file upder DocumentRoot.,and i try

http://myIp/test.jsp        ----------------Error

http://myIP:8080/test.jsp ----------------Error

the info is :

type Status report

message /test.jsp

description The requested resource (/test.jsp) is not available

----------

## newtonian

 *songniao wrote:*   

> yes.i have follown what you say.and i "emerge mod_jk",it sound OK.
> 
> i user http://myIP/index.html  ---------------is OK
> 
> and use http://myIP:8080/index.html     ------------------is OK
> ...

 

Try posting about 10 lines of /var/log/apache2/access.log, error.log and your catalina.out log

Cheers,

----------

