转载

无法在Tomcat下运行PHP脚本

我使用的是Tomcat 6.我已经安装了PHP并尝试使用 PHP

/ JavaBridge在Tomcat中运行PHP.我在Tomcat的webapps目录中部署了JavaBridge.war.运行任何PHP脚本时,我将在下面收到此错误.请帮忙,谢谢你的帮助.

这就是我配置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  –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的错误消息如下:

HTTP Status 500 –
type Exception report
message
description The server encountered an internal error () that prevented  it from fulfilling this request.
exception
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: 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: 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 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

我和你的错误有同样的错误,

你在这里缺少的关键点是:

需要设置PHP CLI(命令行界面)以使用java-php

因为你声称安装了PHP(任何意味着XAMPP / WAMP)

完成以下步骤:

>将PHP添加到PATH环境变量 – Help

>通过运行CMD确认配置>

php-cgi -v

>通过上面的命令,您将看到PHP版本信息

>重启Tomcat

PHP / JavaBridge应该在此之后开始工作.

翻译自:https://stackoverflow.com/questions/7121372/cannot-run-php-script-under-tomcat

原文  https://codeday.me/bug/20190112/502474.html
正文到此结束
Loading...