JK2: tar xvfz jakarta-tomcat-connectors-jk2-src-current.tar.gz cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2 chmod 755 buildconf.sh ./buildconf.sh ./configure --with-apxs2=/usr/local/apache/bin/apxs / ----with-apr-lib=/usr/local/apache/lib / --with-tomcat-41=/usr/local/tomcat / --with-java-home=/usr/local/jdk / --with-jni make liBTool --finish /usr/local/apache/httpd/modules cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/build/jk2/apache2 cp mod_jk2.so /usr/local/apache/modules/ cp libjkjni.so /usr/local/apache/modules/
cd /usr/local/tomcat/logs toUCh jk2.shm usermod -G apache,tomcat apache
启动时运行,编辑文件:/etc/rc.d/rc.local 增加下面两行: su - tomcat -c /usr/local/tomcat/bin/startup.sh /usr/local/apache/bin/apachectl start
三. 修改配置文件, 配置文件如不存在, 就创建. httpd.conf: 注释掉AddDefaultCharset 这行 增加: LoadModule jk2_module modules/mod_jk2.so workers2.properties: 如下 # only at beginnin. In production uncomment it out [logger.apache2] level=DEBUG
# Example socket channel, override port and host. [channel.socket:localhost:8009] info=Ajp13 forwarding over socket tomcatId=localhost:8009
# define the workUntitled 1er [ajp13:localhost:8009] channel=channel.socket:localhost:8009
[uri:/jsp-examples/*] info=Map the jsp-examples webapp worker=ajp13:localhost:8009
[uri:/servlets-examples/*] info=Map the servlets-examples webapp worker=ajp13:localhost:8009 jk2.properties: 如下 ## 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 handler.list=channelSocket,request # # Override the default port for the socketChannel # channelSocket.port=8019 channelSocket.port=8009 # 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 server.xml: 如下 <Server port="8005" shutdown="SHUTDOWN" debug="0"> <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" debug="0"/> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" debug="0"/>
<!-- Global JNDI resources --> <GlobalNamingResources>
<!-- Test entry for demonstration purposes --> <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<!-- Editable user database that can also be used by UserDatabaseRealm to authenticate users --> <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"> <!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 --> <Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" />
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 --> <Connector port="8009" enableLookups="false" redirectPort="8443" debug="0" protocol="AJP/1.3" />
<!-- Define the top level container in our container hierarchy --> <Engine name="Catalina" defaultHost="localhost" debug="0">
<!-- Global logger unless overridden at lower levels --> <Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/>
<!-- Because this Realm is here, an instance will be shared globally -->
<!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" debug="0" resourceName="UserDatabase"/>