阿帕奇,Tomcat的,端口80,8080和其他的东西结合 [英] Combination of Apache, Tomcat, port 80, 8080 and other stuff

查看:135
本文介绍了阿帕奇,Tomcat的,端口80,8080和其他的东西结合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Centos5与运行的httpd,mysql和tomcat6中。所有罚款。我的目标是要实现以下

www.domain.com >>>前锋/代理来www.domain.com:8080/myapplication(由tomcat的服务)
www.domain.com/phpmyadmin >>> www.domain.com/phpmyadmin(被Apache的htdocs自送达)
www.domain.com/* >>>也htdocs文件夹作为服务器D正常阿帕奇含量

我怎样才能做到这一点?任何想法?

THX


解决方案

您只来自Apache服务的htdocs似乎要发送的东西到Tomcat,这是运行一个servletmyappplication的偏差。在这种情况下,


  1. 定义一个工人(有的文本字符串,让我们把它称为myworker)。

  2. 近文件/etc/apache2/apache2.conf中的结尾添加行

- 忽略在后这一行 -

 #在哪里可以找到workers.properties
#更新此路径以匹配您的conf目录的位置(放workers.properties旁边的httpd.conf)
JkWorkersFile /etc/apache2/workers.properties#如果把JK日志
#更新这个路径,以配合您的日志目录位置(放mod_jk.log旁边ACCESS_LOG)
JkLogFile /var/log/apache2/mod_jk.log#设置JK日志级别[调试/错误/信息]
JkLogLevel信息#选择日志格式
JkLogStampFormat[%x%A%D%H:%M:%S%Y]#JkOptions指示发送SSL密钥大小,
JkOptions + ForwardKeySize + ForwardURICompat -ForwardDirectories#JkRequestLogFormat设置请求格式
JkRequestLogFormat%重量%V%T
             JkMount /所有MyApplication / * myworker


  1. 在该目录中,创建一个文件workers.properties,即包含以下内容:

      worker.myworker.type = AJP13
    worker.myworker.host =本地主机
    worker.myworker.port = 8081
    worker.myworker.cachesize = 10
    worker.myworker.cache_timeout = 600
    worker.myworker.socket_keepalive = 1
    worker.myworker.socket_timeout = 300


  2. 编辑线tomcat_inst_dir / conf目录/ server.xml中把一个行

    [连接器端口=8081协议=AJP / 1.3/]


请注意:改变方括号尖括号。
上面一行而来的[服务] ...里面[/服务]标签和出[引擎] ... [/发动机]标签,把它右上面的[引擎]行。


  1. 重新启动Apache和Tomcat

现在的任何请求http://www.domain.com/myapplication/servletName [?票面价值= ...]得到被Apache重定向(端口80)到Tomcat(端口8081),并上servlet的所有MyApplication。我假设你有一个目录TOMCAT_HOME / webapps /下所有MyApplication,从而有一个目录WEB-INF与它的web.xml文件。 servletName上面的是你的[servlet的名称]之间的界定什么... [/ servlet的名称]在该文件中的标签。

我选择了一些8081(随意,只要它不与其他标准的服务冲突,选择你的端口号),这样8080端口仍然是活动您测试http://www.domain.com:8080 /所有MyApplication / servletName(应该产生在端口8080和80相同的输出,apache的端口)。

重要提示:请在上述过程中改变了所有文件的备份副本,这样你就可以恢复你的工作系统,如果以上不工作。我不得不去通过上面的无数次迭代得到它的工作!

祝你好运,希望这个作品出来你 - 。M.S

PS。很抱歉的格式 - 我不可能获得这个更好

I have a Centos5 with running httpd, mysql and tomcat6. All fine. My goal is to achieve the following

www.domain.com >>> forwards/proxies to www.domain.com:8080/myapplication (served by tomcat) www.domain.com/phpmyadmin >>> www.domain.com/phpmyadmin (served by Apache from htdocs) www.domain.com/* >>> also serverd by htdocs folder as "normal" Apache content

How can I achieve this? Any ideas?

THX

解决方案

Your only deviation from apache serving htdocs seems to be sending stuff to tomcat, which is running a servlet "myappplication". In this case,

  1. Define a worker (some text string, lets call it "myworker").
  2. Near the end of file /etc/apache2/apache2.conf, add the lines

--Ignore this line in the post--

# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile /etc/apache2/workers.properties

# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /var/log/apache2/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel info

# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"


             JkMount /myapplication/* myworker

  1. In that directory, create a file "workers.properties", that contains the following:

    worker.myworker.type=ajp13
    worker.myworker.host=localhost
    worker.myworker.port=8081
    worker.myworker.cachesize=10
    worker.myworker.cache_timeout=600
    worker.myworker.socket_keepalive=1
    worker.myworker.socket_timeout=300
    

  2. Edit the line tomcat_inst_dir/conf/server.xml to put in a line

    [Connector port="8081" protocol="AJP/1.3" /]

Note: change the square brackets to angle brackets. The above line goes inside the [service]...[/Service] tags and out of the [Engine] ... [/Engine] tags, put it right above the [Engine] line.

  1. Restart apache and tomcat

Now any request to "http://www.domain.com/myapplication/servletName[?par=value...]" gets redirected by apache (on port 80) to tomcat (on port 8081) and on to the servlet myapplication. I assume you have a directory "tomcat_home/webapps/myapplication", which in turn has a directory WEB-INF with a "web.xml" file in it. "servletName" above is what you define between the [servlet-name]...[/servlet-name] tags in that file.

I chose the number 8081 (feel free to choose your port number as long as it doesnt conflict with other standard services) so that port 8080 is still active for you to test "http://www.domain.com:8080/myapplication/servletName" (should produce same output on ports 8080 and 80, the apache port).

IMPORTANT: Keep a backup copy of all the files changed in the above process, so you can revert back to your working system if the above doesn't work. I had to go through countless iterations of the above to get it working!

Good luck, and hope this works out for you, - M.S.

PS. Sorry about the formatting - I couldnt get this any better

这篇关于阿帕奇,Tomcat的,端口80,8080和其他的东西结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆