修改JKMount路径后,mod_jk失败(apache2.2 + tomcat7)

时间:2014-05-22 09:10:30

标签: jsp servlets apache2 tomcat7 mod-jk

我正在尝试通过mod_jk集成apache2.2和tomcat7。我在网上找到了一些例子并试图找出答案。但对我来说仍然不清楚。 以下是我的配置

Apache配置

/etc/apache2/mods-available/jk.conf:

<IfModule jk_module>
JkWorkersFile /etc/libapache2-mod-jk/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
...

/etc/apache2/mods-available/jk.load:

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so

/etc/libapache2-mod-jk/workers.properties:

workers.tomcat_home=/usr/share/tomcat7
workers.java_home=/usr/lib/jvm/java-1.7.0-openjdk-i386
ps=/
worker.list=ajp13_worker

worker.ajp13_worker.port=8009
worker.ajp13_worker.host=localhost
worker.ajp13_worker.type=ajp13

worker.ajp13_worker.lbfactor=1

worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=ajp13_worker

Tomcat配置

/etc/tomcat6/server.xml:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

以下是我的测试

工作案例

的/ etc / apache2的/位点可用/ 000-默认:

...
JkMount /examples/*/*.jsp ajp13_worker
JkMount /examples/*/servlet/* ajp13_worker
Alias /examples "/usr/share/tomcat7-examples/examples"
<Directory "/usr/share/tomcat7-examples/examples">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        allow from all
</Directory>

失败案例

修改后 / etc / apache2 / sites-available / 000-default to following

...
JkMount /examples3/*/*.jsp ajp13_worker
JkMount /examples3/*/servlet/* ajp13_worker
Alias /examples3 "/usr/share/tomcat7-examples/examples"
<Directory "/usr/share/tomcat7-examples/examples">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        allow from all
</Directory>

尝试http://www.test.com/examples3/jsp/jsp2/el/basic-arithmetic.jsp

时会出现404错误

为什么?

1 个答案:

答案 0 :(得分:0)

我找到了根本原因。这是在/ var / lib / tomcat7 / work / Catalina / localhost / examples3 /中创建编译的jsp类文件的权限问题。不知何故,我在/ var / lib / tomcat7 / work / Catalina / localhost /中创建了examples3。这就是为什么用户tomcat7无法创建从jsp这个文件夹编译的类对象的原因。删除examples3后,它现在工作正常。

drwxr-xr-x 3 tomcat7 tomcat7 4096 Jun 4 17:18例子

drwxr-xr-x 2 root root 4096 Jun 4 17:37 examples3