4

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_pass 127.0.0.1:9000; 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: 192.168.3.1, server: webvm, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", 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 = 127.0.0.1:9000 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

4
  • fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; did you just make that up? does the file /scripts/index.php exist? Commented Dec 2, 2014 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 Commented Dec 2, 2014 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. Commented Sep 27, 2015 at 7:42
  • or @ReynierPM you can set like this fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; Commented Jun 30 at 3:25

2 Answers 2

0

For me issue with "Primary script unknown" while reading response header from upstream was, that one of php extensions got uninstalled, while it's config was still on disk (specifically it was redis module). Checking /etc/php/XX/pool.d/* against what modules have config (.ini files) and should be installed (or config should be removed) fixed issue. After installing one missing module all started to work again.

It wasn't NGINX fault, but PHP extensions issue.

-1

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

1
  • 2
    Why change the php-fpm user, how are .htaccess files relevant when using nginx..? Commented Dec 6, 2014 at 14:28

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.