简体   繁体   中英

Docker php-fpm-alpine: How to supress warnings

I am having the dollowing 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[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. 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.

You could try using the following 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.

Create a simple PHP file with the contents:

<?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.

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.

Hope this helps!

You could simply edit your php.ini file as follows:

 error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE

Or into a php file:

error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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