gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:40:45 24 4
gpt4 key购买 nike

我目前正在试验一个名为 Mosquitto PHP ( https://github.com/mgdm/Mosquitto-PHP/ ) 的 PHP 插件。我已经全部安装好,在“php -m”下它似乎正确显示。

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

<?php

$c = new Mosquitto\Client;
$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 "Finished\n";
?>

这似乎在我的浏览器中返回了“完成”。所以,我决定升级我的游戏,并添加一个 TLS 连接,如记录的那样:

<?php

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

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

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

echo "Finished\n";
?>

我获得了证书,并且确保 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 中打印“完成”,并通过代理发送消息。

这让我觉得这是一种奇怪的权限错误。进一步调查,我在我的日志中发现了这些:

我的 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)。

我认为这个案例应该可以解决您的问题。

更新

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

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

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

关于PHP 在浏览器中返回错误 500,但在 shell 中不返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37634820/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com