2

我有一个这样的 PHP 脚本在 PHP-fpm 7.3 上运行:

<?php
$file = './French-Stories-Martine.zip';
if (headers_sent()) {
    echo 'HTTP header already sent';
} else {
    if (!is_file($file)) {
        header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
        echo 'File not found';
    } else if (!is_readable($file)) {
        header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
        echo 'File not readable';
    } else {
        header($_SERVER['SERVER_PROTOCOL'].' 200 OK');
        header("Content-Type: application/zip");
        header("Content-Transfer-Encoding: Binary");
        header("Content-Length: ".filesize($file));
        header("Content-Disposition: attachment; filename=\"".basename($file)."\"");
        readfile($file);
        exit;
    }
}
?>

我尝试过静态下载这个 zip 文件(意味着没有 PHP 脚本 - 只使用普通的旧 Apache + OpenLiteSpeed 网络服务器),下载速度非常好。没有错。

问题是当我尝试使用此 PHP 脚本下载所述 zip 文件时。下载速度为1/10。

现在,我得出的结论是问题出在 PHP 而不是 WebServer 或服务器本身。我不知道我的 PHP 可能有什么问题?

我正在为 PHP-fpm 使用以下配置:

pm.max_children = 80
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 30

这是我尝试从脚本下载时的 PHP 日志文件:

[08-Nov-2021 00:40:52] WARNING: [pool www] child 3267, script '/www/wwwroot/example.com/my-php-script-dl.php' (request: "GET /my-php-script-dl.php") executing too slow (31.192873 sec), logging
[08-Nov-2021 00:40:52] NOTICE: child 3267 stopped for tracing
[08-Nov-2021 00:40:52] NOTICE: about to trace 3267
[08-Nov-2021 00:40:52] NOTICE: finished trace of 3267
[08-Nov-2021 00:42:30] NOTICE: Reloading in progress ...
[08-Nov-2021 00:42:30] NOTICE: reloading: execvp("/www/server/php/73/sbin/php-fpm", {"/www/server/php/73/sbin/php-fpm", "--daemonize", "--fpm-config", "/www/server/php/73/etc/php-fpm.conf", "--pid", "/www/server/php/73/var/run/php-fpm.pid"})
[08-Nov-2021 00:42:30] NOTICE: using inherited socket fd=8, "/tmp/php-cgi-73.sock"
[08-Nov-2021 00:42:30] NOTICE: using inherited socket fd=8, "/tmp/php-cgi-73.sock"
[08-Nov-2021 00:42:30] NOTICE: fpm is running, pid 5317
[08-Nov-2021 00:42:30] NOTICE: ready to handle connections
[08-Nov-2021 00:42:44] NOTICE: Reloading in progress ...
[08-Nov-2021 00:42:44] NOTICE: reloading: execvp("/www/server/php/73/sbin/php-fpm", {"/www/server/php/73/sbin/php-fpm", "--daemonize", "--fpm-config", "/www/server/php/73/etc/php-fpm.conf", "--pid", "/www/server/php/73/var/run/php-fpm.pid"})
[08-Nov-2021 00:42:44] NOTICE: using inherited socket fd=8, "/tmp/php-cgi-73.sock"
[08-Nov-2021 00:42:44] NOTICE: using inherited socket fd=8, "/tmp/php-cgi-73.sock"
[08-Nov-2021 00:42:44] ERROR: Another FPM instance seems to already listen on /tmp/php-cgi-73.sock
[08-Nov-2021 00:42:44] NOTICE: fpm is running, pid 5539
[08-Nov-2021 00:42:44] ERROR: FPM initialization failed
[08-Nov-2021 00:42:44] NOTICE: ready to handle connections
[08-Nov-2021 00:45:18] NOTICE: Reloading in progress ...
[08-Nov-2021 00:45:18] NOTICE: reloading: execvp("/www/server/php/73/sbin/php-fpm", {"/www/server/php/73/sbin/php-fpm", "--daemonize", "--fpm-config", "/www/server/php/73/etc/php-fpm.conf", "--pid", "/www/server/php/73/var/run/php-fpm.pid"})
[08-Nov-2021 00:45:18] ERROR: Another FPM instance seems to already listen on /tmp/php-cgi-73.sock
[08-Nov-2021 00:45:18] ERROR: FPM initialization failed
[08-Nov-2021 00:45:18] NOTICE: using inherited socket fd=8, "/tmp/php-cgi-73.sock"
[08-Nov-2021 00:45:18] NOTICE: using inherited socket fd=8, "/tmp/php-cgi-73.sock"
[08-Nov-2021 00:45:18] NOTICE: fpm is running, pid 6200
[08-Nov-2021 00:45:18] NOTICE: ready to handle connections
[08-Nov-2021 00:45:44] NOTICE: Reloading in progress ...
[08-Nov-2021 00:45:44] NOTICE: reloading: execvp("/www/server/php/73/sbin/php-fpm", {"/www/server/php/73/sbin/php-fpm", "--daemonize", "--fpm-config", "/www/server/php/73/etc/php-fpm.conf", "--pid", "/www/server/php/73/var/run/php-fpm.pid"})
[08-Nov-2021 00:45:44] NOTICE: using inherited socket fd=8, "/tmp/php-cgi-73.sock"
[08-Nov-2021 00:45:44] NOTICE: using inherited socket fd=8, "/tmp/php-cgi-73.sock"
[08-Nov-2021 00:45:44] ERROR: Another FPM instance seems to already listen on /tmp/php-cgi-73.sock
[08-Nov-2021 00:45:44] ERROR: FPM initialization failed
[08-Nov-2021 00:45:44] NOTICE: fpm is running, pid 6251
[08-Nov-2021 00:45:44] NOTICE: ready to handle connections
[08-Nov-2021 00:47:46] NOTICE: Finishing ...
[08-Nov-2021 00:47:46] NOTICE: exiting, bye-bye!
[08-Nov-2021 00:47:47] NOTICE: fpm is running, pid 6518
[08-Nov-2021 00:47:47] NOTICE: ready to handle connections
4

0 回答 0