Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

OS: Centos PHP: 5.5.6 Nginx: 1.4.4

Nginx conf

server {
listen 80;

root /srv/;
index index.php;
access_log /srv/ main;
error_log /srv/ warn;

autoindex on;

location / {
    try_files $uri $uri/ /index.php;

location ~ \.php$ {

fastcgi_pass unix:/srv/;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_NAME /www$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param SERVER_NAME $host;
    fastcgi_param SCRIPT_FILENAME /www$fastcgi_script_name;
    include fastcgi_params;


php-fpm pool config

listen = /srv/
listen.allowed_clients =
listen.owner = =
listen.mode = 0660
user =
group =
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 50
request_slowlog_timeout = 60
chroot = /srv/
chdir = /www
catch_workers_output = yes
security.limit_extensions = .php .php3 .php4 .php5
env[TMP] = /srv/
env[TMPDIR] = /srv/
env[TEMP] = /srv/
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i
php_admin_value[error_log] = /srv/
slowlog = /srv/
php_admin_flag[log_errors] = on
php_flag[display_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /srv/
php_value[soap.wsdl_cache_dir] = /srv/
php_admin_value[disable_functions] = dl,exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec
php_admin_value[open_basedir] = /srv/

ls -la from /srv

drwxrwx---  8 4096 Dec  2 11:57

ps aux | grep

500      23102  0.0  2.7 702936  7304 ?        S    13:38   0:00 php-fpm: pool
500      23103  0.0  2.7 702936  7308 ?        S    13:38   0:00 php-fpm: pool
500      23104  0.0  2.7 702936  7304 ?        S    13:38   0:00 php-fpm: pool
500      23105  0.0  2.7 702936  7304 ?        S    13:38   0:00 php-fpm: pool
500      23106  0.0  2.7 702936  7340 ?        S    13:38   0:00 php-fpm: pool


uid=500( gid=500( groups=500(,499(nginx)

id nginx

uid=498(nginx) gid=499(nginx) groups=499(nginx),500(

I have error:

Unable to open primary script: /www/index.php (No such file or directory)

I try changees in nginx config file from

fastcgi_param SCRIPT_FILENAME /www$fastcgi_script_name;


fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;

also try:

fastcgi_param SCRIPT_FILENAME www$fastcgi_script_name;

but have error:

Unable to open primary script: /index.php (No such file or directory)

p.s. static files work unde nginx, php scripts dosn't work

what am I doing wrong?

share|improve this question

On the php-fpm pool

You should have

prefix = /srv/

Then fix some the paths to be related to the chroot

chroot = $prefix
listen = tmp/
chdir = /
# yes, this is in /srv/
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
php_admin_value[error_log] = /logs/php-fpm-error.log
php_value[session.save_path] = /srv/
php_value[soap.wsdl_cache_dir] = /wsdlcache
# only paths INSIDE your chroot
php_admin_value[open_basedir] = /www:/lib
# same here, only INSIDE
php_value[include_path] =".:/www:/www/include:/lib"
# this one does not use the chroot
slowlog = /srv/

For the sendmail_path I'm pretty sure this won't work, you would need the utility and librairies and devices goindg with that in yout chroot, usually for chrooted php-fpm you'd better use SMTP on TCP/IP and not sendmail.

On the nginx side it seems OK, you could use fastcgi_pass unix:$document_root/../tmp/; it would also work. Here is what I have on my side:

fastcgi_split_path_info ^(.+\.php)(/.+)$
fastcgi_param SCRIPT_FILENAME /www$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT /www;
fastcgi_param HOME /www;
fastcgi_param PATH_TRANSLATED /www$fastcgi_path_info;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HOSTNAME $server_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;
fastcgi_param  REDIRECT_STATUS    200;
share|improve this answer

@regilero: your example how to setup php-fpm doesn't work, same thing, it's looking for the scripts in:

root /srv/;

not in


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.