k0pernikus
k0pernikus

Reputation: 66609

How to enable access log for php-fpm in docker container?

Note: I am NOT talking about nginx' own access log. That one works fine. This questions is about enabling the php-fpm access.log.


Currently, I am trying to debug the FastCGI sent in stderr: “Primary script unknown” while reading response header from upstream error

One proposed option is to set the access.log entry in the php-fpm.d/www.conf.

access.log = /var/log/$pool.access.log

Now, I have a docker stack and my php-fpm container is build from the php:7.3-fpm-alpine image.

While I have figured out that it stores its php config files at:

/usr/local/etc/php

and I also found the www.conf at:

/usr/local/etc/php-fpm.d/www.conf

So in a local file I add the default content as provided by the image and add at the end:

php_flag[display_errors] = on
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
access.log = /var/log/$pool.access.log

and I copy that file during build into the docker container.

COPY ./.docker/php/www.conf /usr/local/etc/php-fpm.d/www.conf

Yet when I try to access my server, I don't see any log file being created on incoming requests.

What am I missing to activate the php-fpm access log? How can I figure out why I don't see any log?

Upvotes: 2

Views: 9408

Answers (1)

user10691667
user10691667

Reputation:

The way to do this is to send the error and the access logs to the following address:

/proc/self/fd/2

So replace the "file" locations like so:

access.log = /proc/self/fd/2
error_log = /proc/self/fd/2

Then you should be able to inspect the fpm-logs with docker logs [container-id]

Upvotes: 2

Related Questions