Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

Integrate Tomcat With Apache Using mod_jk

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
80 posts
  • Previous
  • 1
  • 2
  • 3
  • 4
  • Next
Author
Message
pvincent
n00b
n00b
User avatar
Posts: 29
Joined: Sat Aug 02, 2003 9:02 pm

mod_jk2 [SOLVED]

  • Quote

Post by pvincent » Mon Mar 22, 2004 7:29 pm

Finally, I succeed. :)
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 ... 17578.html
Last edited by pvincent on Fri Mar 26, 2004 5:47 am, edited 1 time in total.
Top
`djinn`
n00b
n00b
Posts: 15
Joined: Sat Nov 23, 2002 9:52 am
Location: /Texas/Dallas

Servlet-Engine header removal?

  • Quote

Post by `djinn` » Wed Mar 24, 2004 7:46 pm

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 :( Any help would be greatly appreciated :)
Top
najk
n00b
n00b
Posts: 1
Joined: Mon Mar 29, 2004 6:39 pm

Had some trouble

  • Quote

Post by najk » Mon Mar 29, 2004 6:45 pm

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

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

Code: Select all

        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]
Top
pvincent
n00b
n00b
User avatar
Posts: 29
Joined: Sat Aug 02, 2003 9:02 pm

virtual host

  • Quote

Post by pvincent » Tue Mar 30, 2004 5:35 pm

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 ?
Top
BlinkEye
Veteran
Veteran
Posts: 1046
Joined: Tue Oct 21, 2003 7:13 pm
Location: Gentoo Forums

  • Quote

Post by BlinkEye » Tue Apr 06, 2004 11:26 pm

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">:

Code: Select all

  <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>
!
what should i do with

Code: Select all

className="org.apache.coyote.tomcat4.CoyoteConnector"
as i've installed tomcat 5(.0.18)?
Top
BlinkEye
Veteran
Veteran
Posts: 1046
Joined: Tue Oct 21, 2003 7:13 pm
Location: Gentoo Forums

Re: mod_jk2 [SOLVED]

  • Quote

Post by BlinkEye » Tue Apr 06, 2004 11:52 pm

pvincent wrote:Finally, I succeed. :)
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 ... 17578.html
i think none of your ebuilds work (any more).

Code: Select all

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

Code: Select all

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

Code: Select all

SRC_URI="http://apache.mirrors.pair.com/jakarta/tomcat-connectors/jk2/jakarta-tomcat-connectors-jk2-src-current.tar.gz"
Top
BlinkEye
Veteran
Veteran
Posts: 1046
Joined: Tue Oct 21, 2003 7:13 pm
Location: Gentoo Forums

  • Quote

Post by BlinkEye » Tue Apr 06, 2004 11:58 pm

damn. it doesn't work:

Code: Select all

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!
Top
tfunk
n00b
n00b
Posts: 67
Joined: Tue Apr 06, 2004 6:22 am

  • Quote

Post by tfunk » Thu Apr 08, 2004 3:24 am

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
Top
pvincent
n00b
n00b
User avatar
Posts: 29
Joined: Sat Aug 02, 2003 9:02 pm

mod_jk2

  • Quote

Post by pvincent » Thu Apr 08, 2004 3:14 pm

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
Top
tfunk
n00b
n00b
Posts: 67
Joined: Tue Apr 06, 2004 6:22 am

  • Quote

Post by tfunk » Thu Apr 08, 2004 9:35 pm

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!
Top
pvincent
n00b
n00b
User avatar
Posts: 29
Joined: Sat Aug 02, 2003 9:02 pm

time to get a stable ebuild

  • Quote

Post by pvincent » Fri Apr 09, 2004 1:52 pm

Here is your answer : http://www.gentoo.org/doc/en/ebuild-submit.xml
Top
coreutils
n00b
n00b
User avatar
Posts: 25
Joined: Thu Oct 16, 2003 4:40 pm

  • Quote

Post by coreutils » Sun Apr 11, 2004 8:32 pm

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.
8O
Top
SmokinBudda
n00b
n00b
Posts: 46
Joined: Fri Oct 31, 2003 11:31 pm
Location: Da Dirty Dirty

Heh

  • Quote

Post by SmokinBudda » Wed Apr 21, 2004 8:41 pm

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

Code: Select all

<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

Code: Select all

  <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:

Code: Select all

handler.list=channelSocket,request

channelSocket.port=8009

serverRoot=/etc/apache2
apr.NativeSo=/etc/apache2/extramodules/libjkjni.so
My workers.properties says:

Code: Select all

# 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!
Life is a tragedy for those who feel; and a comedy for those who think.
---Chinese Proverb

www.davinatkins.com
Top
SmokinBudda
n00b
n00b
Posts: 46
Joined: Fri Oct 31, 2003 11:31 pm
Location: Da Dirty Dirty

  • Quote

Post by SmokinBudda » Fri Apr 23, 2004 2:24 am

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

Who knew :)

I also changed my jk2.properties to read

Code: Select all

# 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

Code: Select all

# 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...
Life is a tragedy for those who feel; and a comedy for those who think.
---Chinese Proverb

www.davinatkins.com
Top
mathiasb
n00b
n00b
User avatar
Posts: 20
Joined: Tue Mar 25, 2003 12:02 pm
Location: Denmark

  • Quote

Post by mathiasb » Fri Apr 23, 2004 7:39 am

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:

Code: Select all

<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
instead of this:

Code: Select all

<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. :)
Top
Darkstar
n00b
n00b
Posts: 30
Joined: Fri Jul 19, 2002 6:01 am

Totally Frustrated

  • Quote

Post by Darkstar » Fri Apr 23, 2004 5:54 pm

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.
Top
SmokinBudda
n00b
n00b
Posts: 46
Joined: Fri Oct 31, 2003 11:31 pm
Location: Da Dirty Dirty

Final configuration (Apache 2, Tomcat 5 and mod_jk2)

  • Quote

Post by SmokinBudda » Sat Apr 24, 2004 7:59 pm

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)

Code: Select all

/etc/init.d/apache2 stop
/etc/init.d/tomcat stop
Next I set up my directories

Code: Select all

/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

Code: Select all

###
### New Modules added by SBudda
###
LoadModule jk2_module /etc/apache2/extramodules/mod_jk2.so
I also uncommeted

Code: Select all

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

Code: Select all

################# 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)

Code: Select all

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

Code: Select all

<!-- 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)

Code: Select all

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

Code: Select all

chown -R tomcat:tomcat /var/www/[domain]/webapp/
Then I started up tomcat

Code: Select all

/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

Code: Select all

/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!
Life is a tragedy for those who feel; and a comedy for those who think.
---Chinese Proverb

www.davinatkins.com
Top
MrStaticVoid
Tux's lil' helper
Tux's lil' helper
Posts: 114
Joined: Fri Jul 25, 2003 1:36 am
Location: Maryland

  • Quote

Post by MrStaticVoid » Sat Apr 24, 2004 9:03 pm

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 ... howto.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.
Top
etosh
n00b
n00b
Posts: 1
Joined: Tue May 11, 2004 2:39 am
Location: Los Angeles

finally got it working

  • Quote

Post by etosh » Tue May 11, 2004 3:00 am

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:

Code: Select all

# 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

Code: Select all

[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

Code: Select all

## 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

Code: Select all

<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

Code: Select all

<IfModule !mod_jk2.c>

	LoadModule jk2_module                        extramodules/mod_jk2.so

</IfModule>
Top
phuber
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 106
Joined: Tue Aug 19, 2003 3:16 pm
Location: switzerland
Contact:
Contact phuber
Website

  • Quote

Post by phuber » Mon May 31, 2004 4:16 pm

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 :)
Top
Spice
n00b
n00b
User avatar
Posts: 28
Joined: Sun Mar 14, 2004 6:46 pm
Location: Germany

  • Quote

Post by Spice » Tue Jun 01, 2004 4:30 pm

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! :lol:

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
Top
gcombe74
n00b
n00b
User avatar
Posts: 47
Joined: Tue Jan 27, 2004 7:29 pm
Location: Ogden Utah
Contact:
Contact gcombe74
Website

  • Quote

Post by gcombe74 » Fri Jun 11, 2004 4:33 am

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 ... igweb.html
Gentoo Linux go with the best ---- and forget the rest!
Top
barrct
n00b
n00b
Posts: 63
Joined: Tue Apr 13, 2004 1:58 am
Location: Naples, FL
Contact:
Contact barrct
Website

Still not working

  • Quote

Post by barrct » Tue Jul 06, 2004 11:59 pm

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.

Code: Select 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?
Top
barrct
n00b
n00b
Posts: 63
Joined: Tue Apr 13, 2004 1:58 am
Location: Naples, FL
Contact:
Contact barrct
Website

easiest way for me

  • Quote

Post by barrct » Thu Jul 08, 2004 1:41 pm

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?
Top
nilbus
n00b
n00b
Posts: 28
Joined: Mon Jan 19, 2004 5:20 pm
Location: North Carolina State University
Contact:
Contact nilbus
Website

  • Quote

Post by nilbus » Mon Jul 19, 2004 9:38 pm

Since the URL in the original post for mod_jk doesn't work anymore, here it is:
http://www.apache.org/dist/jakarta/tomc ... ectors/jk/
Top
Post Reply

80 posts
  • Previous
  • 1
  • 2
  • 3
  • 4
  • Next

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic