PHP-FPM chroot with chdir
I am trying to setup a site inside of a PHP-FPM chroot. My paths are as follows: chroot = /var/www/ chdir = www/ The chroot works just fine without chdir. But when I add chdir I get this error on php-fpm startup: ERROR: [pool www] the chdir path '/usr/www/' within the chroot path '/var/www/' ('/var/www///usr/www/') does not exist or is not a directory Anybody know why it would append /usr/ to the chdir path? Is there a way to remove it from that path? Also, if I change the chdir path to /www/, I have to browse to http://localhost/www/filename.php to see my file. Isn't the point of chdir to make that unnecessary?
Have you actually prepared a proper chroot for PHP?
Simply setting an arbitrary directory is not enough – you actually need to build the chroot and ensure it includes all necessary libraries, devices and binaries.
Otherwise, basic things like DNS resolution will fail to work and you’ll get random errors, hangs or app segfaults. It sounds like you are mistaking the simplicity of
open_basedir with that of a chroot.
As a start, this script, once customized, should give you a basis for a chroot.
But realistically, if you don’t have much experience with chroots …
- It may not be any more secure than normal if incorrectly set up
- It may be far more insecure than normal and could allow root escalation if incorrectly set up
- You could end up with random issues, that will plague your application over time all caused by a badly built chroot
I would guess security is your goal, but you’re very likely to end up with the exact opposite.
Got help from phpfreaks IRC last night. It was an issue on the Apache side that I needed it to send the “/www” to PHP-FPM.
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Ebook Reviews
- eSport Matches, Skills Tutorials & News
- Entertainment & General News
- Check your public IP Address precisely