首页 > 解决方案 > Docker PHP-Apache 间歇性错误

问题描述

我正在通过一个简单的 PHP 教程学习自动加载。类的代码和自定义自动加载器似乎不是问题。

但是,当它完全没有意义时,我会. . . failed to open stream: No such file or directory in . . .出错。然后我碰巧注意到,当我刷新浏览器几次时,预期的正确输出确实会显示。

因此,它暂时不起作用,然后在几次刷新后就起作用了。我猜它与服务器有关。但是我该如何诊断这个问题呢?

我正在使用以下 docker-compose 文件:

version: "3"

services:
  www:
    image: "php:7.4.24-apache"
    restart: 'always'
    ports:
      - '81:80'
    volumes:
      - ".:/var/www/html"

更新Docker 日志输出

docker logs --follow complete-object-orient-php-developer-course_www_1 | grep Autoloading

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.21.0.2. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.21.0.2. Set the 'ServerName' directive globally to suppress this message
[Tue Oct 05 02:33:20.966439 2021] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.48 (Debian) PHP/7.4.24 configured -- resuming normal operations
[Tue Oct 05 02:33:20.966629 2021] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
[Tue Oct 05 02:33:25.797390 2021] [mpm_prefork:notice] [pid 1] AH00170: caught SIGWINCH, shutting down gracefully
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.21.0.2. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.21.0.2. Set the 'ServerName' directive globally to suppress this message
[Tue Oct 05 02:33:32.385570 2021] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.48 (Debian) PHP/7.4.24 configured -- resuming normal operations
[Tue Oct 05 02:33:32.385663 2021] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
[Wed Oct 06 01:34:55.303031 2021] [php7:error] [pid 20] [client 172.21.0.1:63858] script '/var/www/html/chapter3/namespaces.php' not found or unable to stat
[Wed Oct 06 01:35:05.608696 2021] [php7:error] [pid 31] [client 172.21.0.1:63856] script '/var/www/html/chapter4/namespaces.php' not found or unable to stat
[Wed Oct 06 01:35:15.729637 2021] [php7:error] [pid 19] [client 172.21.0.1:63862] script '/var/www/html/chapter4/namespaces.php' not found or unable to stat
[Wed Oct 06 03:06:49.384397 2021] [php7:error] [pid 18] [client 172.21.0.1:64066] script '/var/www/html/chapter4/autoloader.php' not found or unable to stat

标签: phpdockerapache

解决方案


推荐阅读