简体   繁体   English

Docker php-fpm / nginx设置:php-fpm抛出空白500,没有错误日志

[英]Docker php-fpm/nginx set-up: php-fpm throwing blank 500, no error logs

Git repo of project: https://github.com/tombusby/docker-laravel-experiments (HEAD at time of writing is 823fd22). 项目的Git回购: https//github.com/tombusby/docker-laravel-experiments (HEAD在撰写本文时为823fd22)。

Here is my docker-compose.yml: 这是我的docker-compose.yml:

nginx:
  image: nginx:stable
  volumes:
    - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
  volumes_from:
    - php
  links:
    - php:php
  ports:
    - 80:80

php:
  image: php:5.6-fpm
  volumes:
    - ./src:/var/www/html
  expose:
    - 9000

Into src/ I've created a fresh laravel project. 进入src /我创建了一个新的laravel项目。 This all functions correctly if I swap out index.php for one with a basic echo "hello world"; 如果我将index.php替换为具有基本echo "hello world";一个,则这一切都能正常运行echo "hello world"; and if I use echo "called";exit(); 如果我使用echo "called";exit(); I can identify that part of laravel's index.php does get executed. 我可以确定laravel的index.php的一部分确实被执行了。

It dies at line 53: 它在第53行死亡:

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

I have no idea why this happens, and I've tried using docker exec -it <cid> bash to have a look around my php-fpm container for error logs. 我不知道为什么会发生这种情况,我尝试使用docker exec -it <cid> bash来浏览我的php-fpm容器以查找错误日志。 All the logs are redirected to stderr/stdout (which is collected by docker). 所有日志都被重定向到stderr / stdout(由docker收集)。

Here is the output that docker collects: 这是docker收集的输出:

php_1   | 172.17.0.3 -  06/May/2016:12:09:34 +0000 "GET /index.php" 500
nginx_1 | 192.168.99.1 - - [06/May/2016:12:09:34 +0000] "GET /index.php HTTP/1.1" 500 5 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36" "-"

As you can see "500" does pretty much nothing to help me work out why there was an error, but I can't find any way of getting the stack trace or anything like the proper error logs that apache's php extension would have produced. 正如你所看到的,“500”几乎没有帮助我解决为什么会出现错误,但我找不到任何方法来获取堆栈跟踪或类似apache的php扩展所产生的正确错误日志。

As per our discussion in ##php on freenode... 根据我们在freenode的## php中的讨论......

Your issue is that the php.ini setting "log_errors" is set to Off. 您的问题是php.ini设置“log_errors”设置为Off。

your options are: 你的选择是:

  • set log_errors=On in php.ini 在php.ini中设置log_errors = On
  • set php_admin_flag[log_errors]=On in your pool config (for docker container based on php:5.6-fpm that is in the file /usr/local/etc/php-fpm.conf ) 在你的池配置中设置php_admin_flag [log_errors] = On(对于基于php:5.6-fpm docker容器php:5.6-fpm文件/usr/local/etc/php-fpm.conf中的php:5.6-fpm
  • or possibly set log_errors=On in .user.ini (php's per-dir config, similar to .htaccess) 或者可能在.user.ini中设置log_errors = On(php的per-dir配置,类似于.htaccess)

As I can see your are running request by a Mac, is the docker environment set up on Mac also? 正如我可以看到Mac正在运行请求,是否还在Mac上设置了docker环境? If it is can you, by running bash on the php-fpm container, try to write into the exposed volume? 如果可以,通过在php-fpm容器上运行bash,尝试写入暴露的卷? ( /var/www/html on the container) (容器上的/var/www/html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM