简体   繁体   English

PHP-FPM 和 CHROOT

[英]PHP-FPM and CHROOT

I'm using Lighttpd and php-fpm, I would like to chroot the vhost of each website.我正在使用 Lighttpd 和 php-fpm,我想 chroot 每个网站的虚拟主机。

The pages of the website are in: /home/vhosts/example1.com/web该网站的页面位于: /home/vhosts/example1.com/web

each vhost has the same layer:每个虚拟主机都有相同的层:

/home/vhosts/example1.com/web
/home/vhosts/example2.com/web
/home/vhosts/example3.com/web

I used this kind of path as document-root of the domain (example1.com), I don't know what psychical path I should use to chroot the vhost, I tried:我使用这种路径作为域的文档根目录(example1.com),我不知道应该使用什么心理路径来对虚拟主机进行 chroot,我尝试过:

document-root = /web

chroot = /home/vhosts/example1.com/ (on php-fpm.conf file)

but I always get 404 NOT FOUND error.但我总是收到 404 NOT FOUND 错误。 How can I chroot the vhost?我如何 chroot 虚拟主机?

(Each website has.php and.html pages.) (每个网站都有.php和.html页面。)

In lighttpd.conf:在 lighttpd.conf 中:

server.document-root = "/home/vhosts/example1.com/web"
fastcgi.server = (
  ".php" => (
  "localhost" => (
     "docroot" => "/web",
     "socket" => "/home/vhosts/example1.com/php.socket",
   )
  )
)

In fpm.conf:在 fpm.conf 中:

listen = /home/vhosts/example1.com/php.socket
chroot = /home/vhosts/example1.com/

Use the $prefix & $pool variables in fpm.conf to simplfy configuration for multiple chroots使用 fpm.conf 中的$prefix$pool变量来简化多个 chroot 的配置

[example1.com]
prefix = /home/vhosts/$pool/
listen = $prefix/php.sock
chroot = $prefix

[example2.com]
prefix = /home/vhosts/$pool/
listen = $prefix/php.sock
chroot = $prefix

You may want to use TCP / IP to listen insted of sockets for a fast growing site as it's more stable than using unix sockets You may want to use TCP / IP to listen insted of sockets for a fast growing site as it's more stable than using unix sockets

Don't forget to limit to limit TCP connections by IP address:不要忘记通过 IP 地址限制 TCP 连接:

listen.allowed_clients = 127.0.0.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM