First of all we need to enable option catch_workers_output for fpm.
catch_workers_output boolean
Redirect worker stdout and stderr into main error log. If not set, stdout and stderr will be redirected to /dev/null according to FastCGI specs. Default value: no.
/usr/local/etc/php-fpm.d/www.conf (in my configuration)
catch_workers_output = yes
Or simply edit and save the file manually to uncomment line starting with ;catch_workers_output.
Then we need to configure log file names and locations.
Access log
If you want or need to activate access log at php level:
access.log string
The access log file. Default value: not set
access.log = /var/log/php/fpm-access.log
Or simply edit and save the file manually to uncomment line starting with ;access.log.
You will have this kind of output:
Error log
Of course in production we do not want to display errors to users:
php_flag[display_errors] = off
Or simply edit and save the file manually to uncomment line starting with ;php_flag[display_errors].
Then we must enable error log and define the error log file location :