PHP-FPM 和 CHROOT

发布于 2024-11-04 06:38:42 字数 516 浏览 3 评论 0原文

我正在使用 Lighttpd 和 php-fpm,我想 chroot 每个网站的虚拟主机。

网站的页面位于:/home/vhosts/example1.com/web

每个虚拟主机都有相同的层:

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

我使用这种路径作为域的文档根(example1.com) ,我不知道应该使用什么心理路径来 chroot 虚拟主机,我尝试过:

document-root = /web

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

但我总是收到 404 NOT FOUND 错误。我怎样才能chroot虚拟主机?

(每个网站都有 .php 和 .html 页面。)

I'm using Lighttpd and php-fpm, I would like to chroot the vhost of each website.

The pages of the website are in: /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:

document-root = /web

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

but I always get 404 NOT FOUND error. How can I chroot the vhost?

(Each website has .php and .html pages.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦醒灬来后我 2024-11-11 06:38:42

在lighttpd.conf中:

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

在fpm.conf中:

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

In 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:

listen = /home/vhosts/example1.com/php.socket
chroot = /home/vhosts/example1.com/
策马西风 2024-11-11 06:38:42

使用 $prefix & fpm.conf 中的 $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

您可能需要使用 TCP / IP 侦听 为快速增长的站点插入套接字,因为它比使用 unix 套接字更稳定

不要忘记通过 IP 地址限制 TCP 连接:

listen.allowed_clients = 127.0.0.1

Use the $prefix & $pool variables in fpm.conf to simplfy configuration for multiple chroots

[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

Don't forget to limit to limit TCP connections by IP address:

listen.allowed_clients = 127.0.0.1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文