Answer the question
In order to leave comments, you need to log in
Why doesn't CHROOT work with php-fpm?
I have to chroot my ftp directory on the site. My config php-fpm.conf:
[mysite.com]
listen = /var/run/php7-fpm-chroot-filemanager.sock
chroot = /var/www/mysite.com/fileman
chdir = /
user = filemanuser
group = filemangroup
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
location ~* /fileman/(.+\.php)$
{
root /var/www/mysite.com/;
include /etc/nginx/fastcgi_params;
if (!-f /var/www/mysite.com$fastcgi_script_name) {
return 405;
}
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php7-fpm-chroot-filemanager.sock
fastcgi_param SCRIPT_FILENAME /var/www/mysite.com$fastcgi_script_name;
}
File not found.
2017/02/24 20:12:22 [error] 18390#18390: *108 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.110.25, server: www.mysite.com, request: "GET /fileman/index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7-fpm-chroot-filemanager.sock:", host: "www.mysite.com"
Answer the question
In order to leave comments, you need to log in
chroot is a change of the root ("/") of the file system. PHP having switched to the new root knows nothing about the levels above, for it the root is now /var/www/mysite.com/fileman. Those. when you say - execute script fastcgi_param SCRIPT_FILENAME /var/www/mysite.com$fastcgi_script_name; - it searches from its new root, which means that it actually searches the file system for the file /var/www/mysite.com/fileman/var/www/mysite.com$fastcgi_script_name
If you don't understand why you are cheating, it's better not to use it. There may be many nuances.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question