Vincent.Chan‘s Blog

常用链接

统计

积分与排名

网站

最新评论

配置 Apache 2.2.x + Tomcat 5.5.x

1 Apache端

1.1 编辑APACHE_HOME/conf/httpd.conf

添加以下语句, 把APACHE_HOME改成相应目录.

    LoadModule jk_module modules/mod_jk.so
JkWorkersFile "APACHE_HOME/conf/workers.properties"
JkLogFile "APACHE_HOME/logs/mod_jk.log"
JkMount /*.jsp worker1
JkMount /*/servlet/* worker1

1.2 生成workers.properties配置文件

生成如下配置文件文件,

    worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

2 Tomcat端

2.1 编辑TOMCAT_HOME/conf/server.xml

在Host element下添加相应Context,

    <!-- Test Context -->
<Context path="/test" docBase="APACHE_HOME/htdocs/test" reloadable="true"
crossContext="true"/>

2.2 编辑TOMCAT_HOME/conf/web.xml (可选)

Tomcat 4.1.12之后的版本缺省配置下不能用/servlet/*的方式来调用/WEB-INF/classes路径下的servlet. 4.1.12的RELEASE-NOTES提及以下变化,

Starting with Tomcat 4.1.12, the invoker servlet is no longer available by default in all webapps. Enabling it for all webapps is possible by editing $CATALINA_HOME/conf/web.xml to uncomment the "/servlet/*" servlet-mapping definition.

Using the invoker servlet in a production environment is not recommended and is unsupported. More details are available on the Tomcat FAQ at http://tomcat.apache.org/faq/misc.html#invoker.

其实还需要Tomcat 5.0之后的版本还需要去掉web.xml另一段语句的注释, 蹊跷的是官方文档没提到.

也许因为无法消灭这个安全漏洞, 黔驴技穷的开发人员只好宣布, "Using /servlet/ to map servlets is evil, absolutely evil". 这个解决方案真是convenient, absolutely convenient.

简而言之, 用户需要去掉以下段落的注释,

    <servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>

posted on 2006-05-06 19:06 Vincent.Chen 阅读(1450) 评论(0)  编辑  收藏 所属分类: 杂文


只有注册用户登录后才能发表评论。


网站导航: