Docker Community Forums

Share and learn in the Docker community.

PHP cannot set fastcgi.logging to 0

I have a very simple docker installation consisting of NGINX and PHP via FastCGI on port 9000. I am running Docker Desktop version on Windows 10.

I have configured my Dockerfile so that the PHP container copies “php.ini-production” to “php.ini” and then I copy in my own “php_settings.ini” into “conf.d”.

Currently the only settings I have in “php_settings.ini” are “fastcgi.logging = 0” and “display_errors = on” (this last one is just to confirm the file is being loaded).

Now, if my script has an error then the error is displayed as expected because “display_errors = on”.

However I am finding that “fastcgi.logging = 0” is not stopping PHP from logging all requests that are made, which is completely useless and unwanted and just clogs up the docker logs.

Note that if the PHP script runs phpinfo() it does show that “fastcgi.logging = 0” has been set.

But it does not appear to turn off SAPI logging which is what I want. Certainly, the docker logs contains one line for each request looking something like: - 01/Aug/2020:12:56:25 +0000 “GET /index.php” 200

Does anyone have any suggestion as to how this SAPI logging can be turned off?

Thanks …

For completeness, here is my PHP Dockerfile:

FROM php:7.4-fpm

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY application/php.ini "$PHP_INI_DIR/conf.d/php_settings.ini"

COPY src /var/www/html

CMD ["php-fpm"]

And here is my NGINX Dockerfile:

FROM nginx

COPY web_server/nginx.conf /etc/nginx/conf.d/default.conf
COPY src/public /var/www/html/public

And here is my NGINX configuration file:

error_log /var/log/nginx/error.log;
charset utf-8;

server {
	listen 80 default_server;
	server_name localhost;
	access_log /var/log/nginx/web_access.log;
	root /var/www/html/public;
	index index.php;
	location / {
		try_files $uri /index.php?$query_string;
	location ~ \.php$ {
		try_files $uri =404;
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		fastcgi_pass application:9000;
		fastcgi_index index.php;
		include fastcgi_params;
		fastcgi_param SCRIPT_FILENAME $request_filename;
		fastcgi_param PATH_INFO $fastcgi_path_info;

Ok, for anyone who comes here looking for the same information, I have figured out the solution.

What I needed to do was to create a new file called “zz-nolog.conf” containing:

access.log = /dev/null

and then in my PHP Dockerfile, add the following line:

COPY application/zz-nolog.conf "$PHP_INI_DIR/../php-fpm.d/zz-nolog.conf"