简体   繁体   English

使用自动生成mod_jk.conf配置tomat的server.xml文件

[英]configuring tomat's server.xml file with auto generating mod_jk.conf

I am using apache (2.2.15) and tomcat6 (6.0.24) on CentOS 6.4 and would like to use the feature with tomcat server that generates the mod_jk.conf file automatically by adding: 我在CentOS 6.4上使用apache (2.2.15)tomcat6 (6.0.24) ,并希望通过添加以下内容来自动生成mod_jk.conf文件的tomcat服务器使用该功能:

<Listener className="org.apache.jk.config.ApacheConfig" workersConfig="/usr/share/tomcat6/conf/jk/workers.properties" modJk="/usr/lib/httpd/modules/mod_jk.so" />

in tomcat's server.xml file just before </Engine> tag. 在tomcat的server.xml文件中,就在</Engine>标记之前。 It work just fine and generates the mod_jk.conf file for me. 它工作得很好,并为我生成mod_jk.conf文件。 Here is a copy of the generated mod_jk.conf: 这是生成的mod_jk.conf的副本:

########## Auto generated on Thu Dec 05 08:32:05 PST 2013##########

<IfModule !mod_jk.c>
  LoadModule jk_module "/usr/lib/httpd/modules/mod_jk.so"
</IfModule>

JkWorkersFile "/usr/share/tomcat6/conf/jk/workers.properties"
JkLogFile "/usr/share/tomcat6/logs/mod_jk.log"

JkLogLevel emerg

<VirtualHost localhost>
    ServerName localhost

    JkMount /CallOffice ajp13
    JkMount /CallOffice/* ajp13

    JkMount /Diag289 ajp13
    JkMount /Diag289/* ajp13
</VirtualHost>

The problem is that I need the apps under tomcat to be accessible by IP or DNS name and can't get at my apps under tomcat through apache (http://serverIP/CallOffice/CallOffice.jsp) . 问题是我需要tomcat下的应用程序可以通过IP或DNS名称访问,并且无法通过apache (http://serverIP/CallOffice/CallOffice.jsp)获取tomcat下的应用程序。 According to the documentation here: 根据这里的文件:

http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html

mod_jk.conf can have a VirtualHost tag like: mod_jk.conf可以有一个VirtualHost标签,如:

# All URL goes to tomcat except the one containing /home
<VirtualHost *:80> 

For background info, the following in server.xml generates the <VirtualHost localhost> tag in mod_jk.conf when it is auto-generated: 有关背景信息,server.xml中的以下内容在自动生成时会在mod_jk.conf中生成<VirtualHost localhost>标记:

<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true"          xmlValidation="false" xmlNamespaceAware="false">

Under this configuration, you can't access tomcat apps through apache unless you're on the server using localhost. 在此配置下,除非您使用localhost在服务器上,否则无法通过apache访问tomcat应用程序。 To get a configuration that works, I have to add: 要获得有效的配置,我必须添加:

<Host name="*:80" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">

to tomcat's server.xml file. 到tomcat的server.xml文件。 This makes the mod_jk.conf file look like this: 这使得mod_jk.conf文件看起来像这样:

########## Auto generated on Thu Dec 05 08:38:52 PST 2013##########

<IfModule !mod_jk.c>
  LoadModule jk_module "/usr/lib/httpd/modules/mod_jk.so"
</IfModule>

JkWorkersFile "/usr/share/tomcat6/conf/jk/workers.properties"
JkLogFile "/usr/share/tomcat6/logs/mod_jk.log"

JkLogLevel emerg



<VirtualHost *:80>
    ServerName *

    JkMount /CallOffice ajp13
    JkMount /CallOffice/* ajp13

    JkMount /Diag289 ajp13
    JkMount /Diag289/* ajp13
</VirtualHost>

<VirtualHost localhost>
    ServerName localhost

    JkMount /CallOffice ajp13
    JkMount /CallOffice/* ajp13

    JkMount /Diag289 ajp13
    JkMount /Diag289/* ajp13
</VirtualHost>

This configuration works and I can get to my apps (http://serverIP/CallOffice/CallOffice.jsp) but when I start up tomcat I get the following error: 这个配置有效,我可以访问我的应用程序(http://serverIP/CallOffice/CallOffice.jsp)但是当我启动tomcat时出现以下错误:

Dec 5, 2013 8:38:52 AM org.apache.catalina.core.StandardContext preRegisterJMX
INFO: Error registering ctx with jmx
StandardEngine[Catalina].StandardHost[*:80].StandardContext[/CallOffice] null
javax.management.MalformedObjectNameException: Invalid character ':' in value part of property
javax.management.MalformedObjectNameException: Invalid character ':' in value part of property

Dec 5, 2013 8:38:52 AM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
javax.management.MalformedObjectNameException: Invalid character ':' in value part of property at javax.management.ObjectName.construct(ObjectName.java:617)

Dec 5, 2013 8:38:52 AM org.apache.catalina.core.StandardContext start
SEVERE: Error in resourceStart()
Dec 5, 2013 8:38:52 AM org.apache.catalina.core.StandardContext registerJMX
INFO: Error registering wrapper with jmx
StandardEngine[Catalina].StandardHost[*:80].StandardContext[/CallOffice] null
javax.management.RuntimeOperationsException: Object name cannot be null
javax.management.RuntimeOperationsException: Object name cannot be null`

Tomcat hates seeing any host tag in server.xml that has an '*' in it. Tomcat讨厌在server.xml中看到任何主机标签,其中包含'*'。 But this is needed for my deployment where users sometimes use IP address to access the apps. 但这是我的部署所需要的,用户有时会使用IP地址来访问应用程序。 I know I can just use a static version of mod_jk.conf to get what I need, but I would like to use an auto-generating mod_jk.conf file because new .war files added to tomcat will be configured automatically in mod_jk.conf without having to update a static mod_jk.conf file. 我知道我可以使用mod_jk.conf的静态版本来获得我需要的东西,但我想使用自动生成的mod_jk.conf文件,因为添加到tomcat的新.war文件将在mod_jk.conf中自动配置必须更新静态mod_jk.conf文件。

Any ideas here?? 这里有什么想法? Even though I get the errors in Tomcat's log file when starting, my apps still work..Ignore tomcat's errors?? 即使我在启动时收到Tomcat日志文件中的错误,我的应用程序仍然有用..Ignore tomcat的错误? or go with a static mod_jk.conf file with no virtual tag or <VirtualHost *:80> to get what I want?? 或者使用没有虚拟标记的静态mod_jk.conf文件或<VirtualHost *:80>来获取我想要的内容?

Well here's your answer - go with a static mod_jk.conf file. 那么这是你的答案 - 使用静态mod_jk.conf文件。

Tomcat user list archive Tomcat用户列表存档

The tomcat developers considered this ApacheConfig auto-generation functionality not to be good enough for production, and in tomcat 7, it was removed. tomcat开发人员认为这种ApacheConfig自动生成功能不足以进行生产,而在tomcat 7中,它已被删除。 Presumably the issue was too complex and not high enough priority. 据推测,问题太复杂,优先级不够高。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM