Windows下Apache Tomcat Jk 1.3 简明配置摘要

VN:F [1.9.10_1130]
Rating: 0.0/5 (0 votes cast)
俺不知道配了多少遍这个,每次都忘掉,都要重新搜索N多版本的文档,记录下来备案好了

软件环境

  • Windows XP Home SP3
  • JDK 6.0
  • Apache Tomcat 6.14
  • Apache HTTPD 2.2.x

前置步骤

  1. 确认正确安装Tomcat,在浏览器输入 http://localhost:8080 出现tomcat 欢迎页
  2. 确认正确安装Apache 2.2, 在浏览器输入 http://localhost 出现 It Works! 字样

以上内容,请参考其官方网站:http://tomcat.apache.org http://httpd.apache.org/

下载MOD_JK

请选择适合你系统的JK下载:下载地址

对于apache 2.2 对应的名字为mod_jk-1.2.26-httpd-2.2.4.so

下载后,重命名为 mod_jk.so,放入apache httpd 的 modules目录下

配置Apache HTTPD 2.2

打开其配置文件 httpd.conf

加入载入模块的配置(建议将其加在 mod_rewrite的前面)

LoadModule jk_module modules/mod_jk.so

在配置文件的末端加入

JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

中间使用了workers.properties文件
在conf目录下新建这个文件,包含以下内容

# Define 1 ajp13 worker
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=127.0.0.1
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300

好了,接下来的内容,就是要把某些路径映射到Tomcat服务器去处理。

简单映射子路径

加入这一句就可以了

JkMount /app* worker1

这时候,当你访问 http://localhost/app 就相当于访问 http://localhost:8080/app

使用vhost

LoadModule vhost_alias_module modules/mod_vhost_alias.so

加载conf/extra/httpd-vhost.conf

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

打开该文件,按照你的需要编辑,我加入了如下内容,当然,需要DNS设置等的支持
请替换[]为< >号

[VirtualHost core.ave7.net:80]
ServerAdmin lazing@ave7.net
ServerName core.ave7.net
JkMount /* worker1
[/VirtualHost]

如此,当输入 http://localhost 时,访问httpd原来的资源,输入 http://core.ave7.net 时,相当于访问http://localhost:8080 (修改了hosts文件)

您可能有兴趣的文章:

VN:F [1.9.10_1130]
Rating: 0.0/5 (0 votes cast)
Creative Commons License
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>