php - 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
解决方案
推荐阅读
- android - 身份证上
标签破坏布局 - bash - Curl 在 Jenkins 流水线脚本中返回 Invalid JSON 错误,但在 bash shell 运行或 Jenkins Freestyle 作业中返回预期响应
- java - 稍后如何在调用 save() 的相同方法中使用来自 Jpa 存储库 save() 的结果对象?
- javascript - 如何在 Javascript 中编写 if 语句?
- visual-studio-code - 使本地结构运行时工作时出错
- ruby - 如何在 Ruby2.6.3 中接收来自用户的多个段落?
- oauth-2.0 - Keycloak 作为 Traefik 的身份验证服务在注销时有延迟
- prolog - Prolog - 到两点的距离
- php - 完整图像而不是缩略图
- flutter - 选项卡上的路线导致黑屏