for info how to setup connectors on Apache side. Notice that JkMount /examples/* worker1 mounts worker by context (so that everything in examples is going to be handled by Tomcat), in your configuration you would want to mount by extension (or even just *), something like this:
so that everything matching *.jsp *.do and *.whatever would be handled by Tomcat, and the rest served by apache. Note: JkMount lines need to be inside your definition (in some cases).
mod_jk doesn't use HTTP to connect to Tomcat, so you can disable the HTTP connector (the one that listens to 8080 by default). You will need to enable AJP connector (not sure if it's enabled by default) with a line in server.xml something like this one:
For Tomcat to recognize which application should respond to the calls you would need to do Host configuration and define a Host with a name matching you site name.
Then you define an apache virtual host with DocumentRoot matching the docBase of Tomcat's application and ServerName matching the Tomcat's Host name, like this:
Please note that this setup is not for a WAR file deployment, but rather for an unpacked (exploded, extracted) war file. WAR is a ZIP archive in case you didn't know.
I apologize for making it a bit vague, but it works, and this is the right way to deploy Tomcat applications behind Apache HTTPD.
If you google for it you will find manuals with walkthoughs, this one seems to be a good one.
发布评论
评论(1)
如果没有特定原因使用 mod_proxy 来部署应用程序,那么 Tomcat Connectors / mod_jk 是一个更合适的解决方案。
请参阅
Tomcat 连接器指南
了解如何在 Apache 端设置连接器。请注意,
JkMount /examples/*worker1
通过上下文挂载worker(以便示例中的所有内容都将由 Tomcat 处理),在您的配置中,您可能希望通过扩展挂载(甚至只是*
),类似这样:这样所有匹配 *.jsp *.do 和 *.whatever 的内容都将由 Tomcat 处理,其余的由 apache 处理。 注意: JkMount 行需要位于您的定义内(在某些情况下)。
mod_jk 不使用 HTTP 连接 Tomcat,因此您可以禁用 HTTP 连接器(默认侦听 8080 的连接器)。您需要在
server.xml
中启用 AJP 连接器(不确定默认情况下是否启用),如下所示:For Tomcat to recognize which application should respond to the Calls you need to执行主机配置并定义一个
主机
与您匹配的name
站点名称。然后定义一个 apache 虚拟主机,其
DocumentRoot
与 Tomcat 应用程序的docBase
匹配,ServerName
与 Tomcat 的主机名匹配,如下所示:httpd.conf :
server.xml:
请注意,此设置不适用于 WAR 文件部署,而是用于解压(分解、提取)的 war 文件。 WAR 是一个 ZIP 存档,以防您不知道。
我很抱歉让它有点含糊,但它确实有效,而且这是在 Apache HTTPD 后面部署 Tomcat 应用程序的正确方法。
如果你用谷歌搜索它,你会找到带有演练的手册, 这个似乎是一个不错的。
If there is no specific reason to use mod_proxy to deploy your applications then Tomcat Connectors / mod_jk is a more suitable solution.
Please refer to
Tomcat connectors howto
for info how to setup connectors on Apache side. Notice that
JkMount /examples/* worker1
mounts worker by context (so that everything in examples is going to be handled by Tomcat), in your configuration you would want to mount by extension (or even just*
), something like this:so that everything matching *.jsp *.do and *.whatever would be handled by Tomcat, and the rest served by apache. Note: JkMount lines need to be inside your definition (in some cases).
mod_jk doesn't use HTTP to connect to Tomcat, so you can disable the HTTP connector (the one that listens to 8080 by default). You will need to enable AJP connector (not sure if it's enabled by default) with a line in
server.xml
something like this one:For Tomcat to recognize which application should respond to the calls you would need to do Host configuration and define a
Host
with aname
matching you site name.Then you define an apache virtual host with
DocumentRoot
matching thedocBase
of Tomcat's application andServerName
matching the Tomcat's Host name, like this:httpd.conf:
server.xml:
Please note that this setup is not for a WAR file deployment, but rather for an unpacked (exploded, extracted) war file. WAR is a ZIP archive in case you didn't know.
I apologize for making it a bit vague, but it works, and this is the right way to deploy Tomcat applications behind Apache HTTPD.
If you google for it you will find manuals with walkthoughs, this one seems to be a good one.