doulian5857 2014-01-03 18:52
浏览 51
已采纳

在同一个应用程序中使用JSP和PHP

My application is based on PHP. Now I want to integrate a web-reporter which is written in JSP. So, I have an Apache HTTP Server and an application written in PHP. I even installed Tomcat to serve JSP files and it is running well at 8080 port. I also got mod_jk.so and added a line LoadModule jk_module modules/mod_jk.so to httpd.conf file, but still I can't run JSP files from my application folders (port 80). I guess, there should be extra tuning of httpd.conf file, but I do not know, what exactly should be done.

EDIT My workers.properties looks exactly like this

JkWorkerProperty worker.list=ajp13w
JkWorkerProperty worker.ajp13w.type=ajp13
JkWorkerProperty worker.ajp13w.host=localhost
JkWorkerProperty worker.ajp13w.port=8009

My uriworkermap.properties looks like this

/jsp/*=ajp13w

where jsp is a folder in htdocs, containing jsp files

And finally, my httpd.conf now contains

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule jk_module modules/mod_jk.so

#AddModule     mod_jk.c
#JkWorkersFile C:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/workers.properties
#JkMountFile   C:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/uriworkermap.properties
JkLogFile     C:/Apache/logs/mod_jk.log
JkLogLevel    info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

Each commented line makes it impossible to start the server.

EDIT

I installed a newer version of Tomcat - Tomcat 8.0, but the problem remains unsolved.

EDIT

Judging by this link apache.org, the problem can be solved by changing server.xml (of tomcat) and some changes of httpd.conf (concerning virtual host). But as allways in this world, this article does not provide any concrete examples.

EDIT

I moved one step ahead. The most stupid error which made it impossible to run the server was quotes. So this line in httpd.conf - JkWorkersFile C:/Program Files/Apache Software Foundation/Tomcat 8.0/conf/workers.properties gave me an error, but after three hours of struggle it turned out, that it should be JkWorkersFile "C:/Program Files/Apache Software Foundation/Tomcat 8.0/conf/workers.properties". So, now it runs. However, when I go to localhost/jsp/index.jsp I now see an Apache Tomcat error report: HTTP Status 404 - /jsp/index.jsp. This seems to be the last error, but still I do not know how to deel with it.

EDIT

Now I see it works. Though, I get an unexpected behaviour. I thought I could place JSP files inside htdocs folder, but as it turned out, they should be placed inside tomcat.

  • 写回答

1条回答 默认 最新

  • dtml3340 2014-01-03 20:45
    关注

    For minimal setup.

    workers.properties file example:

    # Minimal jk configuration
    JkWorkerProperty worker.list=ajp13w
    JkWorkerProperty worker.ajp13w.type=ajp13
    JkWorkerProperty worker.ajp13w.host=localhost
    JkWorkerProperty worker.ajp13w.port=8009   
    

    8009 is the default port mod_jk uses to communicate between HTTPD and Tomcat when it forwards requests to Tomcat. If you change it here you have to change it in Tomcat's server.xml too.

    uriworkermap.properties file example:

    /my_tomcat_app_to_expose_to_httpd/*=ajp13w
    

    The * there is a file extension filter. * for all files, *.jsp for just jsp files, etc.

    Any app listed here will be made available via HTTPD.

    In httpd.conf you need:

    LoadModule    jk_module  libexec/mod_jk.so
    AddModule     mod_jk.c
    JkWorkersFile /config_location/workers.properties
    JkMountFile   /config_location/uriworkermap.properties
    JkLogFile     /log_location/mod_jk.log
    JkLogLevel    info
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?