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 --启用魔术引号 --启用 bcmath --启用日历 --启用 ftp --启用套接字 --启用-wddx --启用-mbstring --启用压缩 --启用 exif --with-gd=/usr --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --启用-gd-native-ttf --启用fastcgi --enable-force-cgi-redirect
Tomcat 的错误消息如下:
HTTP 状态 500 -
类型异常报告
消息
描述服务器遇到内部错误(),阻止 它无法满足此请求。
异常
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)根本原因
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)根本原因
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:找不到 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) 注意 根本原因的完整堆栈跟踪可在 Apache Tomcat/6.0.29 日志。
Apache Tomcat/6.0.29
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.
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
--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
The error msgs from Tomcat as follows:
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 causephp.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 causejava.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 causejava.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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也犯了和你一样的错误
您在这里缺少的关键点是:
PHP CLI(命令行界面)需要设置才能与 java-php 一起使用
桥接
,因为您声称已安装 PHP(任何指 XAMPP/WAMP)
请执行以下步骤:
通过运行CMD确认配置>
<前><代码>php-cgi -v
PHP/JavaBridge 应该在此之后开始工作。
I had the same error as yours,
the key point you are missing here is :
PHP CLI(Command Line Interface) needs to be setup to work with java-php
bridge
as you claim to have installed PHP(any means XAMPP/WAMP)
Go through the following steps :
Confirm the configuration by Run CMD>
PHP/JavaBridge should start working after this.
我也有同样的问题。另一个建议是添加
到命令行。相反,我修改了
catalina.sh
文件中的JAVA_OPTS
导出来添加它。这不起作用,但我将其与上面的建议结合起来并添加到
catalina.sh
中。我弹回服务器并连接到 server/JavaBridgeTemplate621/ 并获得 PHP/Java Bridge 设置页面。I had the same problem. Another suggestion had been to add
to the command line. Instead, I modified the
JAVA_OPTS
export in mycatalina.sh
file to add it. That didn't work, but I combined it with the suggestion above and addedto
catalina.sh
. I bounced the server and connected to server/JavaBridgeTemplate621/ and got the PHP/Java Bridge settings page.重新安装并启用 fastcgi 它对我有用!
Reinstall and enable fastcgi it worked for me!