Now we have multiple virtualhots (nginx) under one php-fpm pool. We would like to use it same way with chroot
.
Chroot directive is absolute path /var/www
, but chdir
should be /[domain]/httpdocs
Is it possible to pass some variable (for example $domain
) from nginx to use it in chdir=/$domain/httpdocs
like $pool
?
Finally i figure it out.
nginx virtualhost config
pool config
PHP-FPM chroot troubleshooting
paths have to be redefined in each nginx virtualhost and passed to php-fpm using fastcgi_param
fastcgi.conf allready have definitions for SCRIPT_FILENAME, DOCUMENT_ROOT so directives must be behind include. DOCUMENT_ROOT default value is nginx virtualhost root !!
fastcgi_pass has to be ip:port instead of socket (not available in chroot) (add listen=9000 to pool config)
use nginx more headers module for debug to view variables in response headers (debian package libnginx-mod-http-headers-more-filter)
Complications related to PHP-FPM chroot
https://knzl.at/setting-up-a-chroot-for-php/ https://gist.github.com/nikitasius/7ff0de91e314d955f4e66c76a5c47bf2