简体   繁体   中英

PHP-FPM and CHROOT

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.)

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/

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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