I set up a chroot jail for a user "bob". bob is located in /var/jails/bob
Bob has a site which is located in /var/jails/bob/bobssite.com/public_html
Everything seems to work so far, including the fact that the process is being run with bob's uid (checked with php "exec('whoami')), that is, until I set chroot in the php5-fpm config file for bob's site (/etc/php5/fpm/pool.d/bobssite.com.conf):
[bobssite.com]
; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or /usr) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /var/jails/bob/$pool/public_html/
user = bob
group = webjail
listen = /var/run/php5-fpm_bobssite.com.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever
; possible. However, all PHP paths will be relative to the chroot
; (error_log, sessions.save_path, ...).
; Default Value: not set
chroot = /var/jails/bob/bobssite.com/public_html
chdir = /
Now, when chroot in the above is commented out, everything works. If I set it to like /var/jails/bob/notbobssite php5-fpm doesn't restart/work because it's an invalid path. If I set it to what it's currently set at I get "File not found" when I visit the page, and this in my error.log
[Thu Oct 16 10:46:39 2014] [error] [client myip] FastCGI: server "/usr/lib/cgi-bin/php5-fcgi_bobssite.com" stderr: Primary script unknown
[Thu Oct 16 10:46:39 2014] [debug] mod_deflate.c(700): [client myip] Zlib: Compressed 16 to 24 : URL /php5-fcgi/user.php
So what's going on here? I'm guessing the debug line holds the answer, but I can't figure it out?
Here is my Apache virtual host config file:
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName bobssite.com
ServerAlias www.bobssite.com
DocumentRoot /var/jails/bob/bobssite.com/public_html/
ErrorLog /var/jails/bob/bobssite.com/error.log
CustomLog /var/jails/bob/bobssite.com/access.log combined
<IfModule mod_fastcgi.c>
AddType application/x-httpd-fastphp5 .php
Action application/x-httpd-fastphp5 /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi_bobssite.com
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi_bobssite.com -socket /var/run/php5-fpm_bobssite.com.sock -pass-header Authorization
</IfModule>
</VirtualHost>