[英]Docker php-fpm-alpine: How to supress warnings
I am having the dollowing Dockerfile: 我正在使用Dockerfile:
FROM php:7.0-fpm-alpine
MAINTAINER John Doe <jdoe@example.com>
EXPOSE 9000
VOLUME /var/www/html
VOLUME /var/log/fpm
COPY ./php_config.ini /usr/local/etc/php/php_no_errors.ini
COPY ./src /var/www/html
# Other extra libraries are installed
RUN chown -R www-data:www-data /var/www/html
ENTRYPOINT ["php-fpm"]
And the file php_config.ini
contains: 并且文件
php_config.ini
包含:
php[error_reporting] = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE & ~E_WARNING)
php_flag[display_errors] = off
php_flag[display_startup_errors] = foo
cgi.fix_pathinfo = 0
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
catch_workers_output = yes
But on my application I still receive php warnings and error echoed into the page that got served via the browser. 但是在我的应用程序上,我仍然收到php警告,并且错误回显到通过浏览器提供服务的页面中。 How can I silence them?
我如何使他们沉默?
As the php.ini file you wish to use is not in (i think) a stnard location or has a standard name you will need explicitly define the path to it when running the php-fpm command. 由于您希望使用的php.ini文件不在(我认为)标准位置或没有标准名称,因此在运行php-fpm命令时需要明确定义其路径。
You could try using the following ENTRYPOINT: 您可以尝试使用以下ENTRYPOINT:
ENTRYPOINT ["php-fpm", "-c", "/usr/local/etc/php/php_no_errors.ini"]
It may be worth aswell checking where you php installation is loading its configuration file from. 也许值得检查一下您的php安装从何处加载其配置文件。
Create a simple PHP file with the contents: 创建一个包含以下内容的简单PHP文件:
<?php
phpinfo();
When viewing that file look for the setting: Loaded Configuration File This will tell you the path the PHP config file is being loaded from. 查看该文件时,请查找设置: 加载的配置文件这将告诉您从中加载PHP配置文件的路径。
You could either, copy your file to this path or hard set the path to the .ini file using the -c command as shown above. 您可以将文件复制到此路径,也可以使用-c命令将路径硬设置为.ini文件。
Hope this helps! 希望这可以帮助!
You could simply edit your php.ini file as follows: 您可以按如下方式简单地编辑php.ini文件:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE
Or into a php file: 或放入php文件:
error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.