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 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号