TOMCAT集成APACHE
1 准备
下载软件
1.1 Apache
文件名:
apache_2.2.11-win32-x86-openssl-0.9.8i.msi
下载地址:
http://apache.freelamp.com/httpd/binaries/win32/apache_2.2.11-win32-x86-no_ssl.msi
1.2 Tomcat
文件名:
apache-tomcat-6.0.18.zip
下载地址:
http://labs.xiaonei.com/apache-mirror/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.zip
1.3 mod_jk
文件名:
mod_jk-1.2.27-httpd-2.2.10.so
下载地址:
http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.27/mod_jk-1.2.27-httpd-2.2.10.so
2 安装apache
假设安装目录是:C:\Apache2.2
端口默认80
3 安装tomcat
假设安装路径是:C:\apache-tomcat-6.0.18
端口默认8080
4 配置apache
4.1 拷贝文件mod_jk-1.2.27-httpd-2.2.10.so
拷贝文件mod_jk-1.2.27-httpd-2.2.10.so到C:\Apache2.2\modules。并且改名为mod_jk.so
4.2 建立文件workers.properties
建立文件C:\Apache2.2\conf\workers.properties
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
| 4.3 修改文件httpd.conf
找到C:\Apache2.2\conf\httpd.conf文件。
修改原有DocumentRoot设置
# DocumentRoot"C:/Apache2.2/htdocs"
DocumentRoot"C:/apache-tomcat-6.0.18/webapps"
| 接着在末尾添加如下内容
<Directory "C:/apache-tomcat-6.0.18/webapps/my">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
# Load mod_jk module
# Update this path to match your moduleslocation
LoadModule jk_module modules/mod_jk.so
# Declare the module for <IfModuledirective> (remove this line on Apache 2.x)
# AddModule mod_jk.c
# Where to find workers.properties
# Update this path to match your confdirectory location (put workers.properties next to httpd.conf)
JkWorkersFile conf/workers.properties
# Where to put jk shared memory
# Update this path to match your localstate directory or logs directory
JkShmFile logs/mod_jk.shm
# Where to put jk logs
# Update this path to match your logsdirectory location (put mod_jk.log next to access_log)
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel debug
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S%Y] "
# Send everything for context /examplesto worker named worker1 (ajp13)
JkMount /my/servlet/* worker1
| 相关的官方说明可以在这里找到。
http://tomcat.apache.org/connectors-doc/generic_howto/quick.html
5 配置tomcat
确认C:\apache-tomcat-6.0.18\conf\server.xml配置如下:(默认就是这样一般不需要改动)
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3"redirectPort="8443" />
|
6 添加一个servlet
比如HelloWorldServlet
确认从这个地址能访问到这个servlet
http://127.0.0.1:8080/my/HelloWorldServlet
7 重启tomcat
应该看到如下信息:
2009-3-13 20:54:14org.apache.jk.common.ChannelSocket init
信息: JK:ajp13 listening on /0.0.0.0:8009
|
8 重启apache
如果如下地址也能访问。说明tomcat和apache整合成功
http://127.0.0.1/my/HelloWorldServlet
|