加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP在浏览器中返回错误500,但不在shell中

发布时间:2020-12-13 17:00:43 所属栏目:PHP教程 来源:网络整理
导读:我目前正在尝试一个名为Mosquitto PHP( https://github.com/mgdm/Mosquitto-PHP/)的PHP插件.我把它全部安装好了,在’php -m’下它似乎正确显示. 我正在使用一个小的测试代码来查看它的基本形式是否有效: ?php$c = new MosquittoClient;$c-onConnect(functi
我目前正在尝试一个名为Mosquitto PHP( https://github.com/mgdm/Mosquitto-PHP/)的PHP插件.我把它全部安装好了,在’php -m’下它似乎正确显示.

我正在使用一个小的测试代码来查看它的基本形式是否有效:

<?php

$c = new MosquittoClient;
$c->onConnect(function() use ($c) {
    $c->publish('mgdm/test','Hello',2);
});

$c->connect('test.mosquitto.org');

for ($i = 0; $i < 100; $i++) {
    // Loop around to permit the library to do its work
    $c->loop(1);
}

echo "Finishedn";
?>

这似乎在我的浏览器中返回“完成”.所以,我决定启动我的游戏,并按照文档记录添加TLS连接:

<?php

$c = new MosquittoClient;
$c->onConnect(function() use ($c) {
    $c->publish('mgdm/test',2);
});

$c->setTlsCertificates('mosquitto.org.crt');
$c->connect('test.mosquitto.org','8883');

for ($i = 0; $i < 100; $i++) {
    $c->loop(1);
}

echo "Finishedn";
?>

我拿到了证书,我确保apache2可以读取它并随后将所有权设置为apache2.结果是在我的浏览器中给出了500内部服务器错误.

-rwsrwsrwt  1 www-data     www-data        279 Jun  5 04:12 test.php
-rwxrwxrwx  1 www-data www-data   1078 Jun 30  2012 mosquitto.org.crt

出于好奇,我在shell中导航到脚本并运行它:

sudo php test.php

这导致在我的ssh中打印出“Finished”,并通过代理发送消息.

这让我觉得这是一种奇怪的许可错误.进一步调查,我在我的日志中找到了这些:

我的apache2日志:

mod_fcgid: process /var/www/php-fcgi-scripts/web1/.php-fcgi-starter(20614) exit(communication error),get unexpected signal 11

安装的mog_fcgid是:

libapache2-mod-fcgid 1:2.3.9-1+b1 amd64 FastCGI interface module for Apache 2

就我所知,它与suexec一样启用:

Module fcgid already enabled
Module suexec already enabled

在一小段事件中,我将.php更改为.fcgi并赋予它x权限,现在消息通过代理,但仍然在浏览器中出现500错误.

suexec日志显示:

[2016-06-07 14:05:58]: uid: (5004/web1) gid: (5005/client0) cmd: test.fcgi

在我的ispconfig日志中显示:

[Tue Jun 07 14:08:25.567945 2016] [fcgid:warn] [pid 27861] (104)Connection reset by peer: [client 93.135.88.60:49328] mod_fcgid: error reading data from FastCGI server
[Tue Jun 07 14:08:25.568016 2016] [core:error] [pid 27861] [client 93.135.88.60:49328] End of script output before headers: test.fcgi

我在这里完全不知所措……我需要帮助!!

解决方法

尝试增加php-fcgi的内存(默认情况下为cli memory_limit = -1).

我认为这个案子应该可以解决你的问题.

UPDATE

我已经安装了mosquitto(来自php7分支)并尝试它(从存储库示例运行test.php.php 7.0.7).我有段错误

segfault at 8 ip 00005574a41c753f sp 00007ffc2dc85da0 error 6 in php7.0[5574a3f80000+391000]

看来这是扩展bug.
您可以尝试调试此段错误(https://bugs.php.net/bugs-generating-backtrace.php)并将报告发送给扩展开发人员.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读