我正在运行nginx和php-fpm,我想为每个主机设置jail。 我的设置有点复杂,所以在networking上的教程让我无处可去。
每个站点都有一个目录/var/www/domain.name/
在这个目录里面,会有一个公共/目录,这个目录是网站的根目录,一个logging/目录,这个目录将专门存储该网站的nginx日志,以及chroot文件系统(etc /,usr /等等)
我碰到的第一个问题是,如何configuration它,PHP-FPM无法find通过nginx传递给它的文件。 他们导致“主脚本未知”错误,更糟糕的是,来自PHP-FPM的错误消息不再是冗长的,所以我无法弄清楚nginx传递的path。
主机的php-fpm池configuration如下所示:
[host] user = host group = www-data chroot = /var/www/domain.name chdir = /public listen = 127.0.0.1:900x
每个池的“x”都是递增的。
这个主机的nginxconfiguration如下所示:
server { listen 80; server_name domain.name *.domain.name; root /var/www/domain.name/public; index index.php index.html index.html; location ~ \.php$ { expires epoch; fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi_params; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9001; } }
我猜测,问题是SCRIPT_FILENAME参数,但我已经改变它只是$ fastcgi_script_name,和其他各种组合,但无济于事。
谁能帮忙?
问题在这里:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
你的PHP运行在/var/www/domain.name
的chroot中,但是你的文档根目录是/var/www/domain.name/public
。 所以当你加载/index.php
, SCRIPT_FILENAME
变成/var/www/domain.name/public/index.php
。 但是,在chroot中这是不存在的! 它在/public/index.php
。
你可以做的是在这里改变目录,使它与chroot中的视图匹配:
fastcgi_param SCRIPT_FILENAME /public$fastcgi_script_name;
什么工作是设置在nginx conf中:
root /public;
我已经试过这个和工作,但万一你有MySQL数据库连接,这根本不会工作。 这也是我的限制,使其工作,但由于套接字无法连接到MySQL数据库。