I have added two line in: "/etc/php5/fpm/php-fpm.conf". There are:
chroot = /home/user/www/public_html
chdir = /
In the server section of my: /etc/nginx/sites-available/default:
root /home/user/www/public_html/site.com;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param DOCUMENT_ROOT /site.com;
fastcgi_param SCRIPT_FILENAME /site.com$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED /site.com$fastcgi_script_name;
}
nginx (or fpm I think) tells me: "File not found". Ok I do following:
root /home/user/www/public_html/site.com;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param DOCUMENT_ROOT /home/user/www/public_html/site.com;
fastcgi_param SCRIPT_FILENAME /home/user/www/public_html/site.com$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED /home/user/www/public_html/site.com$fastcgi_script_name;
}
And now all works fine. What's wrong with the chroot in fpm? Yeah and by the way - why do it works now when I have set a chroot value! I thought it maybe uses another config but:
# ps aux | grep php
root 4696 0.0 1.3 221452 13768 ? Ss 16:52 0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
What's my fault? How to find out what's the root of a problem here? It looks like the chroot here doesn't chroot my system :) Do I need to do something else to get chroot working?
Also I have:
# cat /var/log/nginx/site.com-errors.com.log
2014/12/02 17:11:20 [error] 5472#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: ...., server: site.com, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "site.com"
Ubuntu 14.04:
# php5-fpm -v
PHP 5.5.9-1ubuntu4 (fpm-fcgi) (built: Apr 9 2014 17:11:57)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
# nginx -v
nginx version: nginx/1.4.6 (Ubuntu)
Looks like the chroot doesn't work anymore in php5-fpm. It was working for me for a while before.