我有一个Centos5与运行的httpd,mysql和tomcat6中。所有罚款。我的目标是要实现以下
www.domain >>>前锋/代理来www.domain:8080/myapplication(由tomcat的服务)www.domain/phpmyadmin >>> www.domain/phpmyadmin(被Apache的htdocs自送达)www.domain/* >>>也htdocs文件夹作为服务器D正常阿帕奇含量
我怎样才能做到这一点?任何想法?
THX
解决方案您只来自Apache服务的htdocs似乎要发送的东西到Tomcat,这是运行一个servletmyappplication的偏差。在这种情况下,
- 忽略在后这一行 -
#在哪里可以找到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在该目录中,创建一个文件workers.properties,即包含以下内容:
worker.myworker.type = AJP13worker.myworker.host =本地主机worker.myworker.port = 8081worker.myworker.cachesize = 10worker.myworker.cache_timeout = 600worker.myworker.socket_keepalive = 1worker.myworker.socket_timeout = 300
编辑线tomcat_inst_dir / conf目录/ server.xml中把一个行
[连接器端口=8081协议=AJP / 1.3/]
请注意:改变方括号尖括号。上面一行而来的[服务] ...里面[/服务]标签和出[引擎] ... [/发动机]标签,把它右上面的[引擎]行。
现在的任何请求www.domain/myapplication/servletName [?票面价值= ...]得到被Apache重定向(端口80)到Tomcat(端口8081),并上servlet的所有MyApplication。我假设你有一个目录TOMCAT_HOME / webapps /下所有MyApplication,从而有一个目录WEB-INF与它的web.xml文件。 servletName上面的是你的[servlet的名称]之间的界定什么... [/ servlet的名称]在该文件中的标签。
我选择了一些8081(随意,只要它不与其他标准的服务冲突,选择你的端口号),这样8080端口仍然是活动您测试www.domain: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 >>> forwards/proxies to www.domain:8080/myapplication (served by tomcat) www.domain/phpmyadmin >>> www.domain/phpmyadmin (served by Apache from htdocs) www.domain/* >>> 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,
--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
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=300Edit 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.
Now any request to "www.domain/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 "www.domain: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和其他的东西结合
发布评论