php php5-fpm 的 display_errors 不适用于 nginx
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13929314/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
display_errors for php5-fpm not working with nginx
提问by Pranav
I am running nginx with php5-fpm and want to enable the display_errors.
I am running a virtual host, so please help in making a way to enable display_errors, display_startup_errors.
我正在使用 php5-fpm 运行 nginx 并希望启用display_errors. 我正在运行一个虚拟主机,所以请帮助制定一种启用display_errors, 的方法display_startup_errors。
I tried modifying /etc/php5/fpm/php.ini.
我尝试修改/etc/php5/fpm/php.ini.
;display_errors
Default Value: On
Development Value: On
;Production Value: Off
;display_startup_errors
Default Value: On
Development Value: On
;Production Value: Off
;error_reporting
Default Value: E_ALL
Development Value: E_ALL
;Production Value: E_ALL & ~E_DEPRECATED
;html_errors
Default Value: On
Development Value: On
;Production value: Off
;log_errors
Default Value: On
Development Value: On
;Production Value: On
Is it require to have multiple inifiles for each different virtual host, does vhost makes any difference for php configuration ?
ini每个不同的虚拟主机是否需要有多个文件,vhost 对 php 配置有什么影响吗?
I am also trying set_ini(), but it is not showing any effect. And I restarted nginx and php5-fpm after making changes in php.inifile.
我也在尝试set_ini(),但没有显示任何效果。在更改php.ini文件后,我重新启动了 nginx 和 php5-fpm 。
回答by Kevin A. Naudé
The php.ini does nothing for php-fpm.
php.ini 对 php-fpm 没有任何作用。
If you are using php-fpm:You must provide the configuration change in the fpm pool config associated with your web application. Where these are located depends on your system. The probably locations are:
如果您使用的是 php-fpm:您必须在与您的 Web 应用程序关联的 fpm 池配置中提供配置更改。它们位于何处取决于您的系统。大概的位置是:
/etc/php-fpm.d/mydomain.conf(if things have been set up neatly)/etc/php-fpm.conf(if you are only using one conf for php-fpm)
/etc/php-fpm.d/mydomain.conf(如果事情已经安排妥当)/etc/php-fpm.conf(如果你只为 php-fpm 使用一个 conf)
Your config paths are different from mine, so poke around to see what you have in there. Don't make changes in /etc/php-fpm.confif a suitable conf exists in /etc/php-fpm.d/.
你的配置路径与我的不同,所以四处看看你有什么。不要在变化/etc/php-fpm.conf,如果在存在合适的conf /etc/php-fpm.d/。
If you are not using php-fpm:Update php.ini with the correct configuration.
如果您没有使用 php-fpm:使用正确的配置更新 php.ini。
Correct your configuration:In the configuration shown in the question, you have uncommented documentation rather than provided the correct settings. You had better undo those changes, because PHP won't understand them.
更正您的配置:在问题所示的配置中,您没有注释文档而不是提供正确的设置。您最好撤消这些更改,因为 PHP 不会理解它们。
The correct lines for php-fpm are:
php-fpm 的正确行是:
; enable display of errors
php_flag[display_errors] = on
php_flag[display_startup_errors] = on
The correct lines for normal php are:
正常 php 的正确行是:
; enable display of errors
display_errors = On
display_startup_errors = On
Advice:Do not use these options in a production environment. Best wishes.
建议:不要在生产环境中使用这些选项。最好的祝愿。
回答by Chris Burgess
If you have /etc/php5/fpm/php.ini(used in Debian, Ubuntu style config) then changes to this file should take effect, and that configuration may be further overridden per pool by making changes to specific /etc/php5/fpm/pool.d/*.conffiles.
如果您有/etc/php5/fpm/php.ini(在 Debian、Ubuntu 风格的配置中使用),那么对此文件的更改应该会生效,并且可以通过更改特定/etc/php5/fpm/pool.d/*.conf文件来进一步覆盖每个池的配置。
回答by vlad
In my case Zend errors and NGinX - php5 fpm, work like this:
就我而言,Zend 错误和 NGinX - php5 fpm,工作方式如下:
Only I put in public/index.php
只有我投入 public/index.php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
Without If(){...}
没有 If(){...}
But If only to put above code, display error, will give this:
但是如果只是把上面的代码,显示错误,会给出这个:
Parse error: syntax error, unexpected '}', expecting ',' or ';' in /usr/local/nginx/html/ZendSkeletonApplication/module/Album/src/Album/Controller/AlbumController.php on line 12
Another thing! Set up this code:
另一件事!设置此代码:
'display_not_found_reason' => true,
'display_exceptions' => true,
in module.config.php like this:
在 module.config.php 像这样:
'view_manager' => array(
'template_path_stack' => array(
'album' => __DIR__ . '/../view',
'display_not_found_reason' => true,
'display_exceptions' => true,
),
),
I get all errors of an error.log on screen:
我在屏幕上收到 error.log 的所有错误:
Fatal error: Uncaught exception 'Zend\View\Exception\InvalidArgumentException' with message 'Invalid path provided; must be a string, received boolean' in /usr/local/nginx/html/ZendSkeletonApplication/vendor/zendframework/zendframework/library/Zend/View/Resolver/TemplatePathStack.php:201 Stack trace: #0 /usr/local/nginx/html/ZendSkeletonApplication/vendor/zendframework/zendframework/library/Zend/View/Resolver/TemplatePathStack.php(149): Zend\View\Resolver\TemplatePathStack->addPath(true) #1 /usr/local/nginx/html/ZendSkeletonApplication/vendor/zendframework/zendframework/library/Zend/Mvc/Service/ViewTemplatePathStackFactory.php(38): Zend\View\Resolver\TemplatePathStack->addPaths(Array) #2 [internal function]: Zend\Mvc\Service\ViewTemplatePathStackFactory->createService(Object(Zend\ServiceManager\ServiceManager), 'viewtemplatepat...', 'ViewTemplatePat...') #3 /usr/local/nginx/html/ZendSkeletonApplication/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php(939): call_user_func(Array, Object(Zend in /usr/local/nginx/html/ZendSkeletonApplication/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 946
I didn't touch config file as php-fpm in system (Ubuntu 14.04).
我没有在系统(Ubuntu 14.04)中将配置文件作为 php-fpm 使用。

