You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tim Potter <mu...@gmail.com> on 2008/10/10 17:54:34 UTC

Tomcat and apache and jk_mod HowTo

Hello all,

Be kind, this is my first mailing to the usergroup.

 I am implementing a webserver for a group use, where most of the group will
be creating web pages with php and jsp connections.

 This server is running Ubuntu Gutsy (7.10) and may be updated to Hardy
shortly.   In the mean time, currently I'm running apache/2.2.4   with the
mod_user module enabled, and people in the group using public_html
directories to serve their web pages.

I have come to expect that not many in the group will be utilizing jsp as
the scripting language of choice, but would like it to be available, thus I
am trying to implement tomcat and a connector with jk_mod to apache.

I have successfully setup Tomcat (version 6.0.18) with Java 1.6.0_03
(Java(TM) SE Runtime Environment (build 1.6.0_03-b05)), and I have
downloaded the mod_jk-1.2.23-apache-2.2.x-linux-i686.so module and symlinked
/usr/lib/apache2/modules/mod_jk.so to that file.

BTW: I have also setup the user webapp access successfully and can connect
to http://localhost:8090/~username/webapp.jsp

I planned to use this HowTo to get mod_jk configured in Tomcat and Apache,
but am seeing different references and believe this article might be a few
versions behind:
http://tomcat.apache.org/connectors-doc/generic_howto/quick.html

This section:

Here is the minimum which should be set in httpd.conf directly or included
from another file:

# Load mod_jk module
# Update this path to match your modules location
LoadModule    jk_module  libexec/mod_jk.so
# Declare the module for <IfModule directive> (remove this line on Apache
2.x)
AddModule     mod_jk.c
# Where to find workers.properties
# Update this path to match your conf directory location (put
workers.properties next to httpd.con$
JkWorkersFile /etc/httpd/conf/workers.properties
# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile     /var/log/httpd/mod_jk.shm
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log
next to access_log)
JkLogFile     /var/log/httpd/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel    info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# Send everything for context /examples to worker named worker1 (ajp13)
JkMount  /examples/* worker1


I believe there should be some changes to these instructions, and I would
ask that someone with more knowledge than me give me validation and any
pointers to ensuring that this works as planned.

I am creating a file called /etc/apache2/conf.d/mod_jk.conf that contains
the above information with the alterations as follows:
change libexec/mod_jk.so to /usr/lib/apache2/mod_jk.so
comment out the AddModule mod_jk.c line
repace all instances of httpd with apache2
and point the JkWorkersFile to /etc/apache2/conf.d/workers.properties

Does this make sense?

Also,  I've interpreted from
http://tomcat.apache.org/connectors-doc/generic_howto/workers.html
that the workers.properties file should be in $CATALINA_HOME/conf/      is
this not correct?

Is there anything else that needs to be done, other than restarting apache2
and tomcat?

I attempted these changes and stopped tomcat and apache, then started apache
and got the following error:

me@serverbox:~$ sudo /etc/init.d/apache2 start
* Starting web server apache2
                                                                    Syntax
error on line 2 of /etc/apache2/conf.d/workers.properties:
Invalid command 'worker.list=worker1', perhaps misspelled or defined by a
module not included in the server configuration
  [fail]
 I've looked at the log and no jk log is being created, and the error log
doesn't have anything after stopping the apache daemon.  Any help would be
greatly appreciated.

Thanks!

Re: Tomcat and apache and jk_mod HowTo

Posted by Rainer Jung <ra...@kippdata.de>.
Tim Potter wrote:
> Be kind, this is my first mailing to the usergroup.

I'll do my best.

>  This server is running Ubuntu Gutsy (7.10) and may be updated to Hardy
> shortly.   In the mean time, currently I'm running apache/2.2.4   with the
> mod_user module enabled, and people in the group using public_html
> directories to serve their web pages.
> 
> I have come to expect that not many in the group will be utilizing jsp as
> the scripting language of choice, but would like it to be available, thus I
> am trying to implement tomcat and a connector with jk_mod to apache.
> 
> I have successfully setup Tomcat (version 6.0.18) with Java 1.6.0_03
> (Java(TM) SE Runtime Environment (build 1.6.0_03-b05)), and I have
> downloaded the mod_jk-1.2.23-apache-2.2.x-linux-i686.so module and symlinked
> /usr/lib/apache2/modules/mod_jk.so to that file.

Not relevant concerning your observations, but when you start something 
new, you shouldn't use old version without good reasons. Apache httpd is 
at 2.2.9 (soon 2.2.10) and mod_jk is at 1.2.26. Java 6 is at 1.6.0_07.

> BTW: I have also setup the user webapp access successfully and can connect
> to http://localhost:8090/~username/webapp.jsp

Fine.

> I planned to use this HowTo to get mod_jk configured in Tomcat and Apache,
> but am seeing different references and believe this article might be a few
> versions behind:
> http://tomcat.apache.org/connectors-doc/generic_howto/quick.html
> 
> This section:
> 
> Here is the minimum which should be set in httpd.conf directly or included
> from another file:
> 
> # Load mod_jk module
> # Update this path to match your modules location
> LoadModule    jk_module  libexec/mod_jk.so

The default directory is libexec for httpd 1.3.x and modules for httpd 
2.x. You can put any path here as long as the file is there. You can 
even point directly to the versioned file you downloaded without using 
any symlink.

> # Declare the module for <IfModule directive> (remove this line on Apache
> 2.x)
> AddModule     mod_jk.c

Delete this for httpd 2.x.

> # Where to find workers.properties
> # Update this path to match your conf directory location (put
> workers.properties next to httpd.con$
> JkWorkersFile /etc/httpd/conf/workers.properties

You can put the workers.properties file anywhere you like, as long as 
you put the chosen path here. You can even change it's name.

Beware: Depending on your Linux distribution, there might be magic 
directories which should only contain httpd configuration files, because 
the httpd configuration of your distribution might try to read in all 
files in such a magic directory via Include when parsing the httpd 
configuration. The error cited by you below indicates, that this is the 
case here. Your httpd configuration contains an include for 
/etc/httpd/conf/*, so it tries to read all files including 
workers.properties although workers.properties is *not* a general httpd 
configuration file, but instead a special mod_jk file. So put it 
elsewhere and change the path given to JkWorkersFile accordingly.

> # Where to put jk shared memory
> # Update this path to match your local state directory or logs directory
> JkShmFile     /var/log/httpd/mod_jk.shm
> # Where to put jk logs
> # Update this path to match your logs directory location (put mod_jk.log
> next to access_log)
> JkLogFile     /var/log/httpd/mod_jk.log
> # Set the jk log level [debug/error/info]
> JkLogLevel    info
> # Select the timestamp log format
> JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

Delete the JkLogStampFormat. The default should be fine.

> # Send everything for context /examples to worker named worker1 (ajp13)
> JkMount  /examples/* worker1

If you want to forward requests for the URI /examples/*, then this is 
OK, else you need to put the URI here, that you are actually going to 
use, e.g. JkMount /*.jsp worker1.

worker1 here is a name you can choose, but you need to define the 
properties of this worker in thhe JkWorkersFile (workers.properties), 
like IP, Port etc.

> I am creating a file called /etc/apache2/conf.d/mod_jk.conf that contains
> the above information with the alterations as follows:
> change libexec/mod_jk.so to /usr/lib/apache2/mod_jk.so
> comment out the AddModule mod_jk.c line
> repace all instances of httpd with apache2
> and point the JkWorkersFile to /etc/apache2/conf.d/workers.properties
> 
> Does this make sense?

Yes, see above.

> Also,  I've interpreted from
> http://tomcat.apache.org/connectors-doc/generic_howto/workers.html
> that the workers.properties file should be in $CATALINA_HOME/conf/      is
> this not correct?

You can place it in an arbitrary directory, as long as you put the path 
to the file as the value to JkWorkersFile.

> Is there anything else that needs to be done, other than restarting apache2
> and tomcat?

Yes, producing a correct workers.properties file.

> I attempted these changes and stopped tomcat and apache, then started apache
> and got the following error:
> 
> me@serverbox:~$ sudo /etc/init.d/apache2 start
> * Starting web server apache2
>                                                                     Syntax
> error on line 2 of /etc/apache2/conf.d/workers.properties:
> Invalid command 'worker.list=worker1', perhaps misspelled or defined by a
> module not included in the server configuration
>   [fail]

See above, this is because there is some include for any file in 
/etc/apache2/conf in some of your httpd configuration files. 
workers.properties is not understandable by httpd itself, only by 
mod_jk, which will load it separately.

Regards,

Rainer

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org