Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Integrate Tomcat With Apache Using mod_jk
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3, 4  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
pvincent
n00b
n00b


Joined: 02 Aug 2003
Posts: 29

PostPosted: Mon Mar 22, 2004 7:29 pm    Post subject: mod_jk2 [SOLVED] Reply with quote

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%40jakarta.apache.org/msg117578.html


Last edited by pvincent on Fri Mar 26, 2004 5:47 am; edited 1 time in total
Back to top
View user's profile Send private message
`djinn`
n00b
n00b


Joined: 23 Nov 2002
Posts: 15
Location: /Texas/Dallas

PostPosted: Wed Mar 24, 2004 7:46 pm    Post subject: Servlet-Engine header removal? Reply with quote

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 :)
Back to top
View user's profile Send private message
najk
n00b
n00b


Joined: 29 Mar 2004
Posts: 1

PostPosted: Mon Mar 29, 2004 6:45 pm    Post subject: Had some trouble Reply with quote

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:

        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]
Back to top
View user's profile Send private message
pvincent
n00b
n00b


Joined: 02 Aug 2003
Posts: 29

PostPosted: Tue Mar 30, 2004 5:35 pm    Post subject: virtual host Reply with quote

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 ?
Back to top
View user's profile Send private message
BlinkEye
Veteran
Veteran


Joined: 21 Oct 2003
Posts: 1046
Location: Gentoo Forums

PostPosted: Tue Apr 06, 2004 11:26 pm    Post subject: Reply with quote

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:
  <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:
className="org.apache.coyote.tomcat4.CoyoteConnector"
as i've installed tomcat 5(.0.18)?
Back to top
View user's profile Send private message
BlinkEye
Veteran
Veteran


Joined: 21 Oct 2003
Posts: 1046
Location: Gentoo Forums

PostPosted: Tue Apr 06, 2004 11:52 pm    Post subject: Re: mod_jk2 [SOLVED] Reply with quote

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%40jakarta.apache.org/msg117578.html


i think none of your ebuilds work (any more).
Code:
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:
SRC_URI="http://www.apache.org/dist/jakarta/tomcat-connectors/jk2/source/jakarta-tomcat-connectors-jk2-${PV}-src.tar.gz"

to
Code:
SRC_URI="http://apache.mirrors.pair.com/jakarta/tomcat-connectors/jk2/jakarta-tomcat-connectors-jk2-src-current.tar.gz"
Back to top
View user's profile Send private message
BlinkEye
Veteran
Veteran


Joined: 21 Oct 2003
Posts: 1046
Location: Gentoo Forums

PostPosted: Tue Apr 06, 2004 11:58 pm    Post subject: Reply with quote

damn. it doesn't work:

Code:
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!
Back to top
View user's profile Send private message
tfunk
n00b
n00b


Joined: 06 Apr 2004
Posts: 67

PostPosted: Thu Apr 08, 2004 3:24 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
pvincent
n00b
n00b


Joined: 02 Aug 2003
Posts: 29

PostPosted: Thu Apr 08, 2004 3:14 pm    Post subject: mod_jk2 Reply with quote

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
Back to top
View user's profile Send private message
tfunk
n00b
n00b


Joined: 06 Apr 2004
Posts: 67

PostPosted: Thu Apr 08, 2004 9:35 pm    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
pvincent
n00b
n00b


Joined: 02 Aug 2003
Posts: 29

PostPosted: Fri Apr 09, 2004 1:52 pm    Post subject: time to get a stable ebuild Reply with quote

Here is your answer : http://www.gentoo.org/doc/en/ebuild-submit.xml
Back to top
View user's profile Send private message
coreutils
n00b
n00b


Joined: 16 Oct 2003
Posts: 25

PostPosted: Sun Apr 11, 2004 8:32 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
SmokinBudda
n00b
n00b


Joined: 31 Oct 2003
Posts: 46
Location: Da Dirty Dirty

PostPosted: Wed Apr 21, 2004 8:41 pm    Post subject: Heh Reply with quote

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:

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

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

handler.list=channelSocket,request

channelSocket.port=8009

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


My workers.properties says:
Code:

# 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
Back to top
View user's profile Send private message
SmokinBudda
n00b
n00b


Joined: 31 Oct 2003
Posts: 46
Location: Da Dirty Dirty

PostPosted: Fri Apr 23, 2004 2:24 am    Post subject: Reply with quote

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:

# 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:
# 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
Back to top
View user's profile Send private message
mathiasb
n00b
n00b


Joined: 25 Mar 2003
Posts: 20
Location: Denmark

PostPosted: Fri Apr 23, 2004 7:39 am    Post subject: Reply with quote

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:
<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">


instead of this:
Code:
<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. :)
Back to top
View user's profile Send private message
Darkstar
n00b
n00b


Joined: 19 Jul 2002
Posts: 30

PostPosted: Fri Apr 23, 2004 5:54 pm    Post subject: Totally Frustrated Reply with quote

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.
Back to top
View user's profile Send private message
SmokinBudda
n00b
n00b


Joined: 31 Oct 2003
Posts: 46
Location: Da Dirty Dirty

PostPosted: Sat Apr 24, 2004 7:59 pm    Post subject: Final configuration (Apache 2, Tomcat 5 and mod_jk2) Reply with quote

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:

/etc/init.d/apache2 stop
/etc/init.d/tomcat stop

Next I set up my directories
Code:

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

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

I also uncommeted
Code:
Include conf/vhosts/vhosts.conf


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

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

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

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

# 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:
chown -R tomcat:tomcat /var/www/[domain]/webapp/


Then I started up tomcat
Code:
/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:
/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
Back to top
View user's profile Send private message
MrStaticVoid
Tux's lil' helper
Tux's lil' helper


Joined: 25 Jul 2003
Posts: 114
Location: Maryland

PostPosted: Sat Apr 24, 2004 9:03 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
etosh
n00b
n00b


Joined: 11 May 2004
Posts: 1
Location: Los Angeles

PostPosted: Tue May 11, 2004 3:00 am    Post subject: finally got it working Reply with quote

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:
# 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:
[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:
## 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:
<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:
<IfModule !mod_jk2.c>

   LoadModule jk2_module                        extramodules/mod_jk2.so

</IfModule>
Back to top
View user's profile Send private message
phuber
Tux's lil' helper
Tux's lil' helper


Joined: 19 Aug 2003
Posts: 106
Location: switzerland

PostPosted: Mon May 31, 2004 4:16 pm    Post subject: Reply with quote

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 :)
Back to top
View user's profile Send private message
Spice
n00b
n00b


Joined: 14 Mar 2004
Posts: 28
Location: Germany

PostPosted: Tue Jun 01, 2004 4:30 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
gcombe74
n00b
n00b


Joined: 27 Jan 2004
Posts: 47
Location: Ogden Utah

PostPosted: Fri Jun 11, 2004 4:33 am    Post subject: Reply with quote

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
_________________
Gentoo Linux go with the best ---- and forget the rest!
Back to top
View user's profile Send private message
barrct
n00b
n00b


Joined: 13 Apr 2004
Posts: 63
Location: Naples, FL

PostPosted: Tue Jul 06, 2004 11:59 pm    Post subject: Still not working Reply with quote

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:
<%@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?
Back to top
View user's profile Send private message
barrct
n00b
n00b


Joined: 13 Apr 2004
Posts: 63
Location: Naples, FL

PostPosted: Thu Jul 08, 2004 1:41 pm    Post subject: easiest way for me Reply with quote

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?
Back to top
View user's profile Send private message
nilbus
n00b
n00b


Joined: 19 Jan 2004
Posts: 28
Location: North Carolina State University

PostPosted: Mon Jul 19, 2004 9:38 pm    Post subject: Reply with quote

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/
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum