无法在Tomcat下运行PHP脚本 [英] Cannot run PHP script under Tomcat

查看:73
本文介绍了无法在Tomcat下运行PHP脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Tomcat6.我已经安装了PHP,并尝试使用PHP/JavaBridge在Tomcat中运行PHP.我已经在Tomcat的webapps目录中部署了JavaBridge.war.当运行任何PHP脚本时,我将在下面收到此错误.请帮助,谢谢您的帮助.

Am using Tomcat 6. I have installed PHP and try to get PHP running inside Tomcat with PHP/JavaBridge. I have deployed JavaBridge.war inside Tomcat's webapps directory. When running any PHP script, I will get this error below. Please help and I thank you for your assistance.

这就是我配置PHP的方式:

This was how I configure PHP:

./configure --with-mime-magic --with-config-file-path =/usr/local/Zend/etc --with-apxs2 =/usr/local/apache2/bin/apxs --with-libxml-dir =/usr --with-mhash =/usr/local --with-bz2 =/usr --with-curl =/usr --with-gettext =/usr --with-mysql =/usr/local/mysql --with-mcrypt =/usr/local --enable-magic-quotes --enable-bcmath -启用日历 -启用ftp --enable-sockets --enable-wddx --enable-mbstring -启用zip --enable-exif --with-gd =/usr --with-freetype-dir =/usr --with-jpeg-dir =/usr --with-png-dir =/usr --enable-gd-native-ttf --enable-fastcgi --enable-force-cgi-redirect

./configure --with-mime-magic --with-config-file-path=/usr/local/Zend/etc --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr --with-mhash=/usr/local --with-bz2=/usr --with-curl=/usr --with-gettext=/usr --with-mysql=/usr/local/mysql --with-mcrypt=/usr/local --enable-magic-quotes --enable-bcmath --enable-calendar --enable-ftp --enable-sockets --enable-wddx --enable-mbstring --enable-zip --enable-exif --with-gd=/usr --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --enable-fastcgi --enable-force-cgi-redirect

来自Tomcat的错误消息如下:

The error msgs from Tomcat as follows:

HTTP状态500-

HTTP Status 500 -

类型异常报告

消息

说明服务器遇到内部错误(),该错误阻止了 满足此请求.

description The server encountered an internal error () that prevented it from fulfilling this request.

例外

javax.servlet.ServletException: php.java.bridge.http.FCGIConnectException:无法连接到服务器 php.java.servlet.fastcgi.FastCGIServlet.init(FastCGIServlet.java:133) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861) org.apache.coyote.http11.Http11AprProtocol $ Http11ConnectionHandler.process(Http11AprProtocol.java:579) org.apache.tomcat.util.net.AprEndpoint $ Worker.run(AprEndpoint.java:1584) java.lang.Thread.run(Thread.java:662)根本原因

javax.servlet.ServletException: php.java.bridge.http.FCGIConnectException: Could not connect to server php.java.servlet.fastcgi.FastCGIServlet.init(FastCGIServlet.java:133) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861) org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579) org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584) java.lang.Thread.run(Thread.java:662) root cause

php.java.bridge.http.FCGIConnectException:无法连接到服务器 php.java.bridge.http.SocketChannelFactory.test(SocketChannelFactory.java:58) php.java.servlet.fastcgi.FastCGIServlet.init(FastCGIServlet.java:131) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861) org.apache.coyote.http11.Http11AprProtocol $ Http11ConnectionHandler.process(Http11AprProtocol.java:579) org.apache.tomcat.util.net.AprEndpoint $ Worker.run(AprEndpoint.java:1584) java.lang.Thread.run(Thread.java:662)根本原因

php.java.bridge.http.FCGIConnectException: Could not connect to server php.java.bridge.http.SocketChannelFactory.test(SocketChannelFactory.java:58) php.java.servlet.fastcgi.FastCGIServlet.init(FastCGIServlet.java:131) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861) org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579) org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584) java.lang.Thread.run(Thread.java:662) root cause

java.io.IOException:java.net.ConnectException:连接被拒绝 php.java.bridge.http.FCGIConnectException.(FCGIConnectException.java:37) php.java.bridge.http.SocketChannelFactory.test(SocketChannelFactory.java:58) php.java.servlet.fastcgi.FastCGIServlet.init(FastCGIServlet.java:131) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861) org.apache.coyote.http11.Http11AprProtocol $ Http11ConnectionHandler.process(Http11AprProtocol.java:579) org.apache.tomcat.util.net.AprEndpoint $ Worker.run(AprEndpoint.java:1584) java.lang.Thread.run(Thread.java:662)根本原因

java.io.IOException: java.net.ConnectException: Connection refused php.java.bridge.http.FCGIConnectException.(FCGIConnectException.java:37) php.java.bridge.http.SocketChannelFactory.test(SocketChannelFactory.java:58) php.java.servlet.fastcgi.FastCGIServlet.init(FastCGIServlet.java:131) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861) org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579) org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584) java.lang.Thread.run(Thread.java:662) root cause

java.io.IOException:找不到PHP.请安装php-cgi. PHP测试 命令是:[php-cgi,-v] php.java.bridge.Util $ Process.start(Util.java:1145) php.java.servlet.fastcgi.FCGIProcess.start(FCGIProcess.java:68) php.java.bridge.http.SocketChannelFactory.doBind(SocketChannelFactory.java:125) php.java.bridge.http.FCGIConnectionFactory.runFcgi(FCGIConnectionFactory.java:88) php.java.bridge.http.FCGIConnectionFactory $ 1.run(FCGIConnectionFactory.java:109) note备注在Apache中可以找到根本原因的完整堆栈跟踪. Tomcat/6.0.29日志.

java.io.IOException: PHP not found. Please install php-cgi. PHP test command was: [php-cgi, -v] php.java.bridge.Util$Process.start(Util.java:1145) php.java.servlet.fastcgi.FCGIProcess.start(FCGIProcess.java:68) php.java.bridge.http.SocketChannelFactory.doBind(SocketChannelFactory.java:125) php.java.bridge.http.FCGIConnectionFactory.runFcgi(FCGIConnectionFactory.java:88) php.java.bridge.http.FCGIConnectionFactory$1.run(FCGIConnectionFactory.java:109) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.

Apache Tomcat/6.0.29

Apache Tomcat/6.0.29

推荐答案

我遇到了与您相同的错误, 您在这里缺少的要点是:

I had the same error as yours, the key point you are missing here is :

PHP CLI (命令行界面)需要进行 设置 才能使用Java-php 桥

PHP CLI(Command Line Interface) needs to be setup to work with java-php bridge

您声称已安装PHP(任何方式表示XAMPP/WAMP)

as you claim to have installed PHP(any means XAMPP/WAMP)

请执行以下步骤:

  • 将PHP添加到PATH环境变量-帮助
  • 通过运行CMD确认配置>

  • Add PHP to PATH environment variable - Help
  • Confirm the configuration by Run CMD>

php-cgi -v

  • 通过上述命令,您将看到PHP版本信息
  • 重新启动Tomcat
  • PHP/JavaBridge应该在此之后开始工作.

    PHP/JavaBridge should start working after this.

    这篇关于无法在Tomcat下运行PHP脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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