PHP-FPM doesn't write to error log

前端 未结 11 1023
予麋鹿
予麋鹿 2020-11-27 09:12

I\'ve just installed a nginx+php-fpm server. Everything seems fine except that PHP-FPM never writes error to its log.

fpm.conf

[default]
listen = /va         


        
相关标签:
11条回答
  • 2020-11-27 09:52

    This worked for me:

    ; Redirect worker stdout and stderr into main error log. If not set, stdout and
    ; stderr will be redirected to /dev/null according to FastCGI specs.
    ; Default Value: no
    catch_workers_output = yes
    

    Edit:

    The file to edit is the file that configure your desired pool. By default its: /etc/php-fpm.d/www.conf

    0 讨论(0)
  • 2020-11-27 09:52

    There is a bug https://bugs.php.net/bug.php?id=61045 in php-fpm from v5.3.9 and till now (5.3.14 and 5.4.4). Developer promised fix will go live in next release. If you don't want to wait - use patch on that page and re-build or rollback to 5.3.8.

    0 讨论(0)
  • 2020-11-27 09:54

    I'd like to add another tip to the existing answers because they did not solve my problem.

    Watch out for the following nginx directive in your php location block:

    fastcgi_intercept_errors on;
    

    Removing this line has brought an end to many hours of struggling and pulling hair.

    It could be hidden in some included conf directory like /etc/nginx/default.d/php.conf in my fedora.

    0 讨论(0)
  • 2020-11-27 09:56

    in my case I show that the error log was going to /var/log/php-fpm/www-error.log . so I commented this line in /etc/php-fpm.d/www.conf

    php_flag[display_errors]   is commented
    php_flag[display_errors] = on  log will be at /var/log/php-fpm/www-error.log
    

    and as said above I also uncommented this line

    catch_workers_output = yes
    

    Now I can see logs in the file specified by nginx.

    0 讨论(0)
  • 2020-11-27 10:02

    Check the Owner directory of "PHP-FPM"

    You can do:

    ls -lah /var/log/php-fpm/
    chown -R webusr:webusr /var/log/php-fpm/
    chmod -R 777 /var/log/php-fpm/
    
    0 讨论(0)
  • 2020-11-27 10:03

    In my case php-fpm outputs 500 error without any logging because of missing php-mysql module. I moved joomla installation to another server and forgot about it. So apt-get install php-mysql and service restart solved it.

    I started with trying to fix broken logging without success. Finally with strace i found fail message after db-related system calls. Though my case is not directly related to op's question, I hope it could be useful.

    0 讨论(0)
提交回复
热议问题