Tomcat下无法运行PHP脚本

发布于 2024-11-30 07:46:42 字数 3599 浏览 6 评论 0原文

我正在使用 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 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦里°也失望 2024-12-07 07:46:42

我也犯了和你一样的错误
您在这里缺少的关键点是:

PHP CLI(命令行界面)需要设置才能与 java-php 一起使用
桥接

,因为您声称已安装 PHP(任何指 XAMPP/WAMP)

请执行以下步骤:

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

    <前><代码>php-cgi -v

  • 通过上面的命令,您将看到 PHP 版本信息
  • 重新启动 Tomcat

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 :

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

    php-cgi -v
    
  • By the above command you will see PHP version info
  • Restart Tomcat

PHP/JavaBridge should start working after this.

暖阳 2024-12-07 07:46:42

我也有同样的问题。另一个建议是添加

-Dphp.java.bridge.php_exec=/usr/bin/php

到命令行。相反,我修改了 catalina.sh 文件中的 JAVA_OPTS 导出来添加它。这不起作用,但我将其与上面的建议结合起来并添加

-Dphp.java.bridge.php_exec=/usr/bin/php-cgi

catalina.sh 中。我弹回服务器并连接到 server/JavaBridgeTemplate621/ 并获得 PHP/Java Bridge 设置页面。

I had the same problem. Another suggestion had been to add

-Dphp.java.bridge.php_exec=/usr/bin/php

to the command line. Instead, I modified the JAVA_OPTS export in my catalina.sh file to add it. That didn't work, but I combined it with the suggestion above and added

-Dphp.java.bridge.php_exec=/usr/bin/php-cgi

to catalina.sh. I bounced the server and connected to server/JavaBridgeTemplate621/ and got the PHP/Java Bridge settings page.

错爱 2024-12-07 07:46:42

重新安装并启用 fastcgi 它对我有用!

Reinstall and enable fastcgi it worked for me!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文