FastCGI sent in stderr: "Primary script unknown"

Hi,

I try to configure a vhost with Nginx and PHP-FPM.

I have an application with Symfony2.6, i followed this tutorial :

I have this error :
2015/05/05 11:48:32 [error] 5181#0: *5 FastCGI sent in stderr: “Primary
script unknown” while reading response header from upstream, client:
127.0.0.1, server: myserver.local, request: “GET / HTTP/1.1”, upstream:
“fastcgi://127.0.0.1:9000”, host: “myserver.local”

I followed various tutorials on this problem (google is my friend !!)
but it
does not work…

My configuration :

→ Vhost

server {
server_name myserver.local;
root /datas/www/sf_project/web;
location / {
try_files $uri /app.php$is_args$args;
}

    # DEV
    location ~ ^/(app_dev|config)\.php(/|$) {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME

$document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
# PROD
location ~ ^/app.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
internal;
}
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}

→ Nginx.conf
user myuser;

→ php-fpm conf :
user = myuser;
group = myuser;

→ ls -al /datas/www
drwxr-xr-x. 8 myuser myuser 4096 5 mai 11:36 sf_project

→ Permission :
/datas/www/sf_project => 755
/datas/www/sf_project/web/app.php => 644

→ OS / Conf :
Fedora 21 / Nginx 1.6.3 / PHP 5.6.8

Thx for your help

Posted at Nginx Forum:

Hi,

On Tue, May 5, 2015 at 7:01 AM, vincent123456 [email protected]
wrote:

Hi,

I try to configure a vhost with Nginx and PHP-FPM.

I have an application with Symfony2.6, i followed this tutorial :

This tutorial has helped me →
How To Install Linux, Nginx, MySQL, PHP (LEMP) Stack on Debian 7 | DigitalOcean.
Maybe it can help you as well.

Hope that helps,

Regards,


Thiago F.

On Tue, May 05, 2015 at 06:01:26AM -0400, vincent123456 wrote:

Hi there,

I have this error :
2015/05/05 11:48:32 [error] 5181#0: *5 FastCGI sent in stderr: “Primary
script unknown” while reading response header from upstream, client:
127.0.0.1, server: myserver.local, request: “GET / HTTP/1.1”, upstream:
“fastcgi://127.0.0.1:9000”, host: “myserver.local”

That error pretty much always means that the fastcgi server cannot find
the file that it thinks it was told to use.

Can you see in your fastcgi server logs what file the fastcgi server
thinks that was?

If not, you may be able to see in your nginx error logs, at debug level,
what fastcgi param values were sent. (You may see these using “tcpdump”
too, if that is simpler to set up.)

The specific fastcgi param that the fastcgi server uses depends on the
server, but it is commonly SCRIPT_FILENAME. If more that one value is
sent, which one the server chooses depends on the server.

The filename that nginx sends in the fastcgi param must be from the
perspective of the fastcgi server – so if the fastcgi server runs in
a chroot, what nginx sends must be adapted.

If you “ls -ld” every directory on the path to the file, do they all
have
“x” permission for the fastcgi-server user?

Good luck with it,

f

Francis D. [email protected]