【发布时间】:2015-12-07 13:09:13
【问题描述】:
我在 Debian X64 上工作,我有托管多个 webapps 的 tomcat,运行良好。
我有一个 Apache 网络服务器正在运行,它托管一个 CMS,并且我想在调用 www.domain-cms.com 时打开它。
现在,Tomcat 有 2 个 web 应用程序,它们会根据 www.domain-tom1.com 和 www.domain-tom2.com 等 URL 再次调用
现在我的问题是如何同时运行并根据 URL 进行区分。我已经完成了以下更改,请让我知道我缺少什么。
Tomcat 的 server.xml:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat">
<Connector port="80" protocol="org.apache.coyote.http11.Http11NioProtocol" compression="force" compressionMinSize="1024"
connectionTimeout="20000" maxPostSize="5242880"
URIEncoding="utf-8"
compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/x-javascript,application/javascript"/>
<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxPostSize="5242880" SSLEnabled="true" maxThreads="200" compre$
compressionMinSize="1024" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS"
keystoreFile="keystorefile" keystorePass="PASSWORD" URIEncoding="utf-8"
compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/x-javascript,application/javascript"/>
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"/>
<Host name="domain-first.com" autoDeploy="true" unpackWARs="true" appBase="tooltank_webapps">
<Alias>www.domain-first.com</Alias>
<Context path=""/>
</Host>
<Host name="domain-second.com" autoDeploy="true" unpackWARs="true" appBase="aupair_webapps">
<Alias>www.domain-second.com</Alias>
<Context path=""/>
</Host>
<Connector port="8010" protocol="AJP/1.3" redirectPort="443" URIEncoding="utf-8"
compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/x-javascript,application/javascript"
/>
</Engine>
apache2.conf:
我已经在里面添加了这个,但是我想根据 URL 重定向,但不知道要添加什么。
<IfModule jk_module>
JkWorkersFile /etc/apache2/workers.properties
JkLogLevel INFO
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
// I think below is wrong, I want to redirect based on URL.
SetEnvIf Request_URI "/error/*" no-jk
SetEnvIf Request_URI "/blog*" no-jk
JkMount / tomcat
JkMount /* tomcat
</IfModule>
(END)
workers.properties 文件:
worker.list=tomcat
# Set properties for worker (ajp13)
worker.worker.type=ajp13
worker.worker.host=127.0.0.1
worker.worker.port=8010
(END)
现在每当我尝试启动 Apache 时,都会出现错误:
[....] Restarting web server: apache2(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
failed!
如何连接 Apache 服务器和 tomcat 并根据 URL 并行提供 CMS 和 webapps。请告诉我。谢谢你。 :-)
【问题讨论】:
标签: java apache tomcat webserver mod-jk