| http://tomcat.apache.org/tomcat-3.3-doc/mod_jk-howto.html |
By Gal Shachor <shachor@il.ibm.com>
mod_jk is a replacement to the elderly mod_jserv. It is a completely new Tomcat-Apache plug-in that handles the communication between Tomcat and Apache.
Several reasons:
You will need to get to know a new simplified configuration mechanism. The advantage is that learning this mechanism will give you a head start if you want to deploy Tomcat on Apache and other web servers, such as Microsoft's Internet Information Server (IIS) and the iPlanet Enterprise Web Server.
In this document I am going to use a few terms, so let's define them:
| Term | Meaning |
|---|---|
| Worker Process | A worker is a tomcat instance that is running to serve servlet requests coming from the web server. In most cases there is only a single worker (the one and only tomcat process) but sometimes you will run multiple workers to achieve load balancing or site partitioning. Each worker is identified to the web server by the host were it is located, the port where it listens and the communication protocol used to exchange messages. |
| In-Process Worker | This is a special worker. Instead of working with a Tomcat process residing on another process, the web server opens a JVM and executes Tomcat inside the web server process address space. Our discussion in this document is not going to get into this special worker. |
| Web Server Plug-in/Tomcat Redirector | For Tomcat to cooperate with any web server it needs an "agent" to reside in the web server and send him servlet requests. This is the web server plug-in, and in our case the web server plug-in is mod_jk. The redirector usually comes in the shape of a DLL or shared object module that you plug into the web server. |
| Plug-in Configuration | We need to configure the web server plug-in so that it knows where the different Tomcat workers are and to which of them it should forward requests. This information, accompanied with some internal parameter, such as the log level, comprises the plug-in configuration. |
| Web Server Configuration | Each web server has some configuration that defines its behavior, e.g. on which port to listen, what files to serve, what web server plug-ins to load, etc. You will need to modify your web server configuration to instruct it to load the Tomcat redirector mod_jk. |
mod_jk can be obtained in two formats - binary and source. Depending on the platform you are running your web server on, a binary version of mod_jk may be available. It is recommended to use the binary version if one is available. If the binary is not available, follow the instructions for building mod_jk from source. Notes at the end of this section offer recommendations for specific platforms.
Binaries for mod_jk are available for several platforms in the same area as the Tomcat Binary Release. The binaries are located in subdirectories by platform. For some platforms, such as Windows, this is the typical way of obtaining mod_jk since most Windows systems do not have C compilers. For others, the binary distribution of mod_jk offers simpler installation.
For example, the Tomcat 3.3 Release at http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.3/bin/ contains the following:
| linux/i386 | Contains mod_jk.so for Apache 1.3 for the standard API as well as EAPI and mod_jk.so for Apache 2.0 |
| netware/i386 | Contains the mod_jk.nlm and nsapi.nlm |
| win32/i386 | Contains the mod_jk.dll for Windows as well as other useful binaries. |
Check the site for the latest binaries.
Note: The version of mod_jk is not dependent on the version of Tomcat. The Tomcat 3.3 distribution of mod_jk will function correctly with other 3.x versions of Tomcat, such as Tomcat 3.2.1.
mod_jk is available in source distribution for all Windows and most Unix platforms. The source for mod_jk is included in the Binary Distribution of Tomcat in the TOMCAT_HOME/native/mod_jk/ directory. This directory is organized by Web Server name and version. Each directory contains the source as well as the appropriate build scripts, make files, or project files.
The redirector was developed using Visual C++ version 6.0, so having this environment is a prerequisite if you want to perform a custom build.
The steps that you need to take are:
MSDEV mod_jk.dsp /MAKE ALL
If msdev is not in your path, enter the full path to msdev.exe. Also, ApacheCore.lib is expected to exist in the APACHE1_HOME\src\Debug or APACHE1_HOME\src\Release (or the older APACHE1_HOME\src\CoreD or APACHE1_HOME\src\CoreR) directories before linking will succeed. You will need to build enough of the Apache source to create the required librarie(s).
This will build both release and debug versions of the redirector plug-in (mod_jk).
An alternative will be to open mod_jk.dsp in msdev and build it using the build menu.
Build mod_jk.so. Following are three techniques you can try, in order of simplicity:
# JAVA_INCLUDE="-I ${JAVA_HOME}/include -I ${JAVA_HOME}/include/linux"
Finally, you can try to build it manually. Run the apxs command that came with your apache distribution (hint: look in /usr/local/apache/bin, /usr/sbin, or wherever you installed apache). Type the command all on one line.
For Linux:
apxs -o mod_jk.so -I../jk -I/usr/local/jdk/include -I/usr/local/jdk/include/linux -c *.c ../jk/*.cYour build may fail because the object files from the ../jk directory have been compiled to the current directory, rather than their source directory. Running gcc -shared -o mod_jk.so *.o should finish the build.
For Solaris:
Use the build-solaris.sh script as follows:
# sh build-solaris.shThis will build and install mod_jk.so in your apache/libexec directory. This script contains settings for your Java and Apache home locations. Make sure that these are set according to your installation. The default settings are JAVA_HOME=/usr/java and APACHE_HOME=/usr/local/apache. If your installation is different, you will need to edit the build-solaris.sh script and change these values appropriately.
See README.solaris located in TOMCAT_HOME/native/mod_jk/apache1.3 for more information.
If the build script does not work, you can also build mod_jk as follows:
$APACHE_HOME/bin/apxs -o mod_jk.so -DSOLARIS -I../jk -I/usr/java/include -I/usr/java/include/solaris -c *.c ../jk/*.c
For HP-UX 11.00:
Use the build-hpux.sh script as follows:
# sh build-hpux.shThis will build and install mod_jk.so in your apache/libexec directory. This script contains settings for your Java and Apache home locations. Make sure that these are set according to your installation. The default settings are JAVA_HOME=/opt/java1.3 and APACHE_HOME=/usr/local/apache. If your installation is different, you will need to edit the build-hpux.sh script and change these values appropriately.
Also note that there are two HP-UX build scripts. One script was written to build mod_jk without JNI support using GNU GCC. The other script builds mod_jk with JNI support, however, this script requires the HP ANSI C Compiler (not the stripped down C compiler included with HP-UX to rebuild the kernel). The HP Compiler is required because the dlopen() and related shared libraries are only available for 64-bit applications and reliable 64-bit compilation is not available with the current version of GCC.
The build-hpux.sh script should also work for HP-UX 10.00.
See README.hpux located in TOMCAT_HOME/native/mod_jk/apache1.3 for more information.
For other Unixes (including FreeBSD):
The build-hpux-cc.sh script should be modifiable for IRIX and AIX. Edit the script and change the APACHE_HOME and JAVA_HOME locations as required.
If you are using EAPI, try adding -DEAPI to the apxs command after mod_jk.so.
If apxs fails with apxs:Break: Command failed with rc=255, it may have been damaged by mod_ssl. Search for:
my $CFG_LD_SHLIB = q(); # substituted via Makefile.tmpl my $CFG_LDFLAGS_SHLIB = q(); # substituted via Makefile.tmpland change to:
my $CFG_LD_SHLIB = q(ld); # substituted via Makefile.tmpl my $CFG_LDFLAGS_SHLIB = q(-G); # substituted via Makefile.tmplIf you've installed Java in another directory, adjust accordingly.
For other Unixes you should be able to work it out, but remember that the order of the arguments to apxs is important!.
There are several Makefiles in the other directories under the TOMCAT_HOME/native/mod_jk/ directory. You should also check the Tomcat documentation for specific information related to other web servers.
This section details the configuration that is required for the Apache Web Server to support mod_jk.
Include TOMCAT_HOME/conf/auto/mod_jk.conf
Example:
Include /usr/local/jakarta-tomcat/conf/auto/mod_jk.conf
This will tell Apache to use directives in the mod_jk.conf file in the Apache configuration. This file is created by starting Tomcat with the "jkconf" option. Tomcat will initialize, write the configuration file and then exit. This may be done while an instance of Tomcat is running. Options for controlling how the mod_jk configuration file is generated are described in the configuring Tomcat section below [Configuring Tomcat].
NOTE: If you plan to use the Tomcat generated configuration, skip the rest of this section and continue with the Configuring Tomcat section.
Custom configurations can be created by enabling the auto-configuration and copying the TOMCAT_HOME/conf/auto/mod_jk.conf file to your own configuration file, such as TOMCAT_HOME/conf/jk/mod_jk.conf.
The basic configuration is as follows:
LoadModule jk_module libexec/mod_jk.so AddModule mod_jk.c JkWorkersFile /usr/local/jakarta-tomcat/conf/workers.properties JkLogFile /usr/local/apache/logs/mod_jk.log JkLogLevel info JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
Use mod_jk's JkMount directive to assign specific URLs to Tomcat. In general the structure of a JkMount directive is:
JkMount <URL prefix><Worker name>For example the following directives will send all requests ending in .jsp or beginning with /servlet to the "ajp13" worker, but jsp requests to files located in /otherworker will go to "remoteworker".
You can use the JkMount directive at the top level or inside <VirtualHost> sections of your httpd.conf file.JkMount /*.jsp ajp13 JkMount /servlet/* ajp13 JkMount /otherworker/*.jsp remoteworker
To have Tomcat generate the configuration file, start Tomcat with the "jkconf" option. Tomcat will initialize, write the configuration file, and then exit. This may be done while an instance of Tomcat is running.
The generation of the mod_jk configuration file is controlled by the ApacheConfig module. The default installation of Tomcat 3.3 comes with the ApacheConfig directive already present in the TOMCAT_HOME/conf/server.xml.
Note: Generating the mod_jk configuration file on demand is new in Tomcat 3.3. Older versions of Tomcat create the auto-config file without a directive in server.xml and generate it each time Tomcat is started. The new ApacheConfig directive in Tomcat 3.3 allows for additional configuration options as detailed later in this section. For older versions of Tomcat, refer to the documentation that came with that version.
If you have special needs, for example mounting URL prefixes that are not the default, you can use this file as a base for your customized configuration and save the results in another file. If you manage the Apache configuration yourself you'll need to update it whenever you add a new context.
Note that you must restart tomcat and apache after adding a new context; Apache doesn't support configuration changes without a restart. Also the file TOMCAT_HOME/conf/auto/mod_jk.conf is generated when tomcat starts, so you'll need to start Tomcat before Apache. Tomcat will overwrite TOMCAT_HOME/conf/auto/mod_jk.conf each startup so customized configuration should be kept elsewhere. For example, copy TOMCAT_HOME/conf/auto/mod_jk.conf to TOMCAT_HOME/conf/jk/mod_jk.conf before making changes. You'll need to start Tomcat with the "jkconf" option once to generate this file with your configuration for the first time.
It is also possible to specify the location of the auto generated files by setting options in the <ApacheConfig /> block. The following details the syntax:
where options can include any of the following attributes:< ContextManager ... > ... <ApacheConfig options /> ... < /ContextManager >
... <ApacheConfig configHome="/home/mydir" /> ...
Note: The default mod_jk configuration file generated by:
differs from the file generated by Tomcat 3.2.x. In Tomcat 3.3, the default is to forward all requests to Tomcat for Tomcat's contexts (i.e. forwardAll="true"), excluding the root context. This helps ensure that behavior configured in web.xml files will function properly. The configuration that best matches Tomcat 3.2.x behavior is:<ApacheConfig />
<ApacheConfig forwardAll="false" noRoot="false"
jkConfig="conf/mod_jk.conf-auto" jkDebug="error" />With this configuration, JSP and servlet requests to the root context will be served from Tomcat's ROOT webapp. Other requests, such as for static files, will be served from Apache's DocumentRoot directory. If Apache's DocumentRoot isn't updated to point to Tomcat's ROOT webapp, then the root context will malfunction. For example, JSP's that reference ".gif" files in Tomcat's ROOT webapp will not be able to display them since they won't be found under Apache's DocumentRoot directory. The default installation of Tomcat 3.3 comes with connectors for both protocols in the TOMCAT_HOME/conf/server.xml. The default choice by the ApacheConfig directive will be to using the "ajp13" worker which uses the Ajpv13 protocol. Even though mod_jk uses the Ajpv13 by default, you shouldn't remove the Ajpv12 connector present in the server.xml file. The Ajpv12 connector is also used for shutting down Tomcat.
Here's an example configuration which probably reflects many real-world setups. A site is using Tomcat and Apache with two virtual hosts (one of them using HTTPS as well, which we're assuming is being handled by mod_ssl).
URLs ending in .jsp and beginning with /servlet are handled by Tomcat, the rest are handled by Apache. The files for each Host are server out of /web/host1 and /web/host2 respectively.
The example are over-simplified and incomplete but should get you started. Also note, this form virtual host setup is new in Tomcat 3.3 and later - this example won't work with Tomcat 3.2 and earlier..
. . <Ajp12Connector port="8007" /> <Ajp13Connector port="8009" /> . |
|
# Setup for Solaris system # workers.tomcat_home=/usr/local/jakarta-tomcat workers.java_home=/usr/java ps=/ worker.list=ajp12, ajp13 # Definition for Ajp13 worker (Ajp12 left to readers imagination) # worker.ajp13.port=8009 worker.ajp13.host=localhost worker.ajp13.type=ajp13 |
# Load mod_jk # LoadModule jk_module libexec/mod_jk.so AddModule mod_jk.c # Configure mod_jk # JkWorkersFile /usr/local/jakarta-tomcat/conf/jk/workers.properties JkLogFile /usr/local/apache/logs/mod_jk.log JkLogLevel info # First Virtual Host. # <VirtualHost 10.0.0.1:80> DocumentRoot /web/host1 ServerName host1.apache.org JkMount /*.jsp ajp13 JkMount /servlet/* ajp13 </VirtualHost> # Second Virtual Host. Also accessible via HTTPS # <VirtualHost 10.0.0.2:80> DocumentRoot /web/host2 ServerName host2.apache.org JkMount /*.jsp ajp13 JkMount /servlet/* ajp13 </VirtualHost> <VirtualHost 10.0.0.2:443> DocumentRoot /web/host2 ServerName host2.apache.org SSLEngine On JkMount /*.jsp ajp13 JkMount /servlet/* ajp13 </VirtualHost> |
A. The primary mechanism for support is through the Tomcat Documentation included in the TOMCAT_HOME/doc directory. These documents are viewable via browser through Tomcat http://localhost:8080/doc/index.html. Documentation is also available on the Apache Jakarta web site for Tomcat at http://jakarta.apache.org/tomcat/tomcat-3.3-doc/index.html.
For additional help, the best resource is the Tomcat Users Discussion list. You should start by searching the mail list archives located at http://www.mail-archive.com/tomcat-user@jakarta.apache.org/ or http://mikal.org/interests/java/tomcat/index.jsp before you post questions to the list. If you are unable to locate the answer to your question in the archive, you can post questions about Tomcat or mod_jk to the user list for assistance. Make sure that you include the version of Apache and Tomcat that you are using as well as the platform you are running on. http://jakarta.apache.org/site/mail.html
A. Starting with Tomcat 3.3, the source for mod_jk is included with the binary distribution, in the native/mod_jk directory. You can also download the Source Distribution of Tomcat to obtain the source for mod_jk, which is how it was obtained in versions prior to Tomcat 3.3. The Binary Distributions of mod_jk are available at the same location as the Binary Distribution of Tomcat. The mod_jk binaries are located in subdirectories by platform. But in May 2001, the jakarta-tomcat-connectors was started and you'll find here up to date featured mod_jk (ie: new protocols AJP14/WARP)
A. Ajp13 is a newer protocol, it's faster, and it works better with SSL. You almost certainly want to use it. There is more information in the workers.properties howto document.
A. The Ajp13 protocol keeps an open socket between Tomcat and Apache. The latest release of mod_jk (the one found since Tomcat 3.3-m2 and J-T-C) handle the network failure. But with previous release of mod_jk, you may have to restart Apache as well.
A. Many versions of Apache use a modified API, known at Extended API. For example, Apache using mod_ssl and the Apache present in certain recent Linux distributions. So if you have an 'Extended Apache', you need to use mod_jk.so-eapi, and use mod_jk.so-noeapi for standard Apache. It's wise to avoid using EAPI modules on standard API Apache and standard API modules on EAPI Apache. Always be sure to have the mod_jk.so for your version of Apache.
A. It's related to Apache EAPI. The message 'mod_jk.so is garbled - perhaps this is not an Apache module DSO ?' just told you are trying to install a mod_jk.so DSO module that was compiled on an Apache using EAPI, such as Apache-mod_ssl or Apache from Redhat distro 6.2/7.0. However, your system is using the standard Apache with the normal API.
A. Also related to EAPI, the message '[warn] Loaded DSO /usr/lib/apache/mod_jk.so uses plain Apache 1.3 API, this module might crash under EAPI! (please recompile it with -DEAPI)', the mod_jk.so was compiled under normal Apache with standard API and you are trying to install the module on an Apache using EAPI.
A. The workers.properties howto document has considerably more in-depth information than this one, and is worth a look. You could also try searching the mailing list archives for "mod_jk" or look at the source.
A. APXS is a Perl script that is created when you build the Apache web server from source. Chances are that if you are getting these errors and you obtained Apache as a binary distribution, that APXS is not configured correctly for your system. Your best bet is to get the Apache source from http://httpd.apache.org and build it yourself. Use the following for a basic build (read the Apache docs for other options):
# cd /usr/local/src # gzip -dc apache_1.3.19.tar.gz|tar xvf - # cd apache_1.3.19 # ./configure --prefix=/usr/local/apache \ --enable-module=most \ --enable-shared=max # make # make install
Note: The above steps assume that you downloaded the Apache source and placed it in your /usr/local/src directory.
Not Found The requested URL /login/j_security_check was not found on this server. |
JkMount /*.jsp ajp13 |
JkMount /*.vm ajp13 |
|
<form method="post" action="j_security_check"> |
JkMount /*.vm ajp13 JkMount /login/j_security_check ajp13 |
This document was originally created by Gal Shachor
Revisions by (Alphabetical)
Mike Braden <mikeb@mwbinc.com>
Mike Bremford
Chris Pepper
With help from countless others on the tomcat-dev and tomcat-user lists!
Copyright ©1999-2001 The Apache Software Foundation |
相关资料:
jkmount不转发php等
JkMount /*.jsp controller
JkMount /*.action controller
JKUnmount /*.
JKmount /*.htm controller
Jkmount /*.html controller
JkMount把匹配的转发到指定服务器.
JkUnMount把匹配的不转发到指定服务器.
JkUnMount选项的级别高于JkMount. 但是如果 /*的话 这个级别我觉得是有问题的。
单独有JkMount规则有效,但单独有JkUnMount无效,JkUnMount与JkMount要成对出现.
httpd-vhosts.conf配置实例
- <VirtualHost *:80>
- DocumentRoot "/webapps/WZBIZ_V10"
- ServerName www.****.com
- ServerAlias ****.com
- ErrorLog "logs/****.com-error_log"
- <Directory "/webapps/WZBIZ_V10">
- Options FollowSymLinks
- AllowOverride None
- Order deny,allow
- Allow from all
- </Directory>
- JkMount /dwr/* tomcat01
- JkMount /* tomcat01
- DirectoryIndex index.html
- </VirtualHost>
相关连接:
tomcat.apache.org/connectors-doc/
It is quite useful and interesting too.
VIRT 的上限是64G,也就是36位, cat /proc/cpuinfo的结果是:addre
昨天要准备用线程重写webbench,试验了下Fedora Linux 2.6.35.14
不明白您的具体的意思是什么?
已经发送到你QQ邮箱
http://www.2mysite.net/scriptencoder/screnc.asp 站长你好,看
你好,我发现一个问题,就是从mysqld2同步过来的数据,在mysqld1的
晕,我说是怎么回事情,原来我和你一样,忘记设置了活动分区