I have installed Nginx 1.6.2 with PHP-FPM (PHP 5.5.18) under CentOS 6.6 server. I didn't touch nothing else but /etc/nginx/conf.d/default.conf file where I made some changes (see below):

server {
    listen       80;
    server_name  webvm devserver ;

    location / {
        root   /var/www/html;
        index  index.php index.html index.htm;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;

    location ~ \.php$ {
        try_files      $uri =404;
        root           /var/www/html;
        include        fastcgi_params;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

After restart Nginx and try to access http://devserver/index.php file I get this error:

2014/12/01 19:48:51 [error] 5014#0: *6 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client:, server: webvm, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://", host: "devserver"

I have checked also permissions/owner for /var/www/html with ls -l command and this is the output:

#ls -l /var/www/html/
total 4
-rw-r--r-- 1 root root 23 Dec  1 19:29 index.php

I did not touch anything under PHP-FPM pool so /etc/php-fpm.d/www.conf have the default configuration:

listen =
user = apache
group = apache

Could be permissions the issue?

I have read several posts here (as for example 1,2,3) talking around the same error and possible solutions and tried to apply to my situation but can't get it to works so I need some help here from any, what I'm doing wrong?

Note: I get out commented lines from the file showed since aren't relevant

  • fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; did you just make that up? does the file /scripts/index.php exist? – AD7six Dec 2 '14 at 9:08
  • 1
    @AD7six nope, that's the problem I forgot to change that line to fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; which means set the right path, thanks for your tip – ReynierPM Dec 2 '14 at 11:34
  • I had this issue in OS X after successfully setting it up on a Amazon Linux instance. I used a $document_root$fastcgi_sript_name; but after exhausting all other permission and service checks I finally just added root /usr/local/var/www/domainname; and bang it started working. Only sharing this comment as I was pulling my hair out for 3 days with a similar issue even though root was defined elsewhere in the .conf file. – Mark Sep 27 '15 at 7:42

change www.conf

user = nginx 
group = nginx

change fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; into

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

and also check, do you have httacess file in /var/www/html. usually this cause that problem

| improve this answer | |
  • 2
    Why change the php-fpm user, how are .htaccess files relevant when using nginx..? – AD7six Dec 6 '14 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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