make
(动态的安装了mod_jk,安装程序作了:
cp .libs/mod_jk.so /usr/local/apache/modules/mod_jk.so
cp .libs/mod_jk.lai /usr/local/apache/modules/mod_jk.la
cp .libs/mod_jk.a /usr/local/apache/modules/mod_jk.a
)
Apache related parameters :
Parameter | Description |
---|---|
--with-apxs[=FILE] |
FILE is the location of the apxs tool. Default is finding apxs in PATH. It builds a shared Apache module. It detects automaticly the Apache version. |
--with-apache=DIR |
DIR is the path where apache sources are located. The apache sources should have been configured before configuring mod_jk. DIR is something like: /home/apache/apache_1.3.33 It builds a static Apache module. |
--enable-maitainer-mode |
Build mod_jk enabling maintainer or DEBUG mode. |
--enable-prefork |
Build mod_jk without all the pthread code, better support apache prefork mode. |
JNI related parameters :
Parameter | Description |
---|---|
--enable-jni |
Build the JNI worker and so the build process will require some informations about your Java Environment. Most of the options are autodetected. |
--with-java-home=DIR |
DIR is the patch to the JDK root directory. Something like: /opt/java/jdk12 |
--with-os-type=SUBDIR |
SUBDIR is the os-type subdirectory, configure should guess it correctly. |
--with-arch-type=SUBDIR |
SUBDIR is the arch subdirectory, configure should guess it correctly. |
--with-java-platform=VAL |
VAL is the Java platform 1 is 1.1.x and 2 is for 1.2 anf higher, configure should guess it correctly. |
Examples of configure use :
?/P>
Apache 2.x build
[user@host] ~ $ ./configure [user@host] ~ $ make [user@host] ~ $ su -c 'make install' |
?/P>
Apache 2.x build with JNI support
[user@host] ~ $ ./configure --with-java-home=${JAVA_HOME} --with-java-platform=2 \ --enable-jni |
- Module Name: mod_jk.c
- Content handlers: yes
- Configuration Phase Participation: Create Server Config, Merge Server Configs
- Request Phase Participation: Translate Path
- Module Directives:
JkWorkersFile - the name of a worker file for the Jakarta servlet containers
JkMountFile - the name of a mount file for the Jakarta servlet uri mapping
JkAutoMount - automatic mount points to a Tomcat worker
JkMount - A mount point from a context to a Tomcat worker
JkUnMount - A no mount point from a context to a Tomcat worker
JkMountCopy - Should the base server mounts be copied to the virtual server
JkLogFile - Full path to the Jakarta Tomcat module log file
JkShmFile - Full path to the Jakarta Tomcat module shared memory file
JkShmSize - Size of the shared memory file in KBytes
JkLogLevel - The Jakarta Tomcat module log level, can be debug, info, error or emerg
JkLogStampFormat - The Jakarta Tomcat module log format, follow strftime synthax
JkRequestLogFormat - The Jakarta mod_jk module request log format string
JkAutoAlias - The Jakarta mod_jk module automatic context apache alias directory
JkHTTPSIndicator - Name of the Apache environment that contains SSL indication
JkCERTSIndicator - Name of the Apache environment that contains SSL client certificates
JkCIPHERIndicator - Name of the Apache environment that contains SSL client cipher
JkSESSIONIndicator - Name of the Apache environment that contains SSL session
JkKEYSIZEIndicator - Name of the Apache environment that contains SSL key size in use
JkExtractSSL - Turns on SSL processing and information gathering by mod_jk
JkOptions - Set one of more options to configure the mod_jk module
JkEnvVar - Adds a name of environment variable that should be sent to servlet-engine
JkWorkerProperty - Set workers.properties formated directive
- Current Configuration:
#加载mod_jk
LoadModule jk_module modules/mod_jk.so
#配置
<IfModule mod_jk.c>
JkWorkersFile conf/workers.properties #设置mod_jk的配置
JkLogFile logs/mod_jk.log #设置日志位置
</IfModule>
#文件类型匹配
<IfModule mod_jk.c>
JkMount /*.jsp loadbalancer #将所有的jsp请求交给loadbalancer[mod_jk的负JkMount /*.do loadbalancer #载均衡器]
JkMount /servlet/* loadbalancer
</IfModule>
#设置默认索引页
DirectoryIndex index.jsp
http://tomcat.apache.org/connectors-doc/config/workers.html
The generic workers.properties directive is in the form:
worker.<worker name>.<directive>=<value>
Mandatory directives are the one that each worker must contain. Without them the worker will be unavailable or will misbehave.
Directive | Default | Description |
---|---|---|
type |
|
Type of the worker (can be one of ajp13, ajp14, jni, lb or status). The type of the worker defines the directives that can be applied to the worker. AJP13 worker is the preferred worker type that JK uses for communication between web server and Tomcat. This type of worker uses sockets as communication channel. For detailed description of the AJP13 protocol stack browse to AJPv13 protocol specification http://tomcat.apache.org/connectors-doc/common/ajpv13a.html |
下面是对server.xml的说明:
Each workers.properties directive consists of three words separated by dot. The first word is always worker. The second word is the worker name that can be any name. The worker name reflects the name of the jvmRoute defined in Tomcat's server.xml configuration file.
The name of the worker can contain only the alphanumeric characters [a-z][A-Z][0-9] and is case insensitive.
Worker1 is index.jsp
<html>
<body bgcolor="red">
Session ID:<%=request.getSession().getId()%>
</body>
</html>
Worker2 is index.jsp
</html>
<html>
<body bgcolor="blue">
Session ID:<%=request.getSession().getId()%>
</body>
</html>