我应该在我的站点上为我的 ftp 目录使用 chroot:我的 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
我的 nginx.conf 部分:
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.
在nginx的日志中:
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"
没有 chroot 选项,一切正常。我哪里有错误?请帮忙。
使用File not found和Primary script unknown,查看
SCRIPT_FILENAME
变量。该变量将脚本的路径名传递给
php-fpm
. 在php-fpm
chroot 环境中运行时,路径名必须相对于 chroot 目录。您已经使用
location
指令中的正则表达式捕获了大部分修改后的路径名。例如: