1

so I'm trying to run for the first time the nginx web server with php5-fpm on a debian wheezy server

Hitting a php file display simply File not found

I have done my research (waste a lot of hours actually ;), there are a lot of people that have similar problems, yet I didn't succeed to correct it with what worked for them.

I still have the same error :

$ tail /var/log/nginx/access.log /var/log/nginx/error.log /var/log/php5-fpm.log | less

==> /var/log/nginx/error.log <==

2013/10/26 21:36:00 [error] 6900#0: *1971 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream,

I have tried a lot of things, it's hard to remember what.

I have put my config files on github

Currently, the nginx.conf configuration uses this...

server {
  server_name mydomain.tld;
  root /srv/data1/test;

   location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include         fastcgi_params;
    }
}

/etc/php5/fpm/pool.d/www.conf contains listen = 127.0.0.1:9000

I have tried the unix socket version, same thing. fastcgi_pass unix:/var/run/php5-fpm.sock;

I made sure the server is started

$ netstat -alnp | grep LISTEN

tcp 0 0 127.0.0.1:9000 0.0.0.0:*
LISTEN 6913/php-fpm.conf) tcp 0 0 127.0.0.1:3306
0.0.0.0:* LISTEN 4785/mysqld tcp 0 0 0.0.0.0:842 0.0.0.0:* LISTEN
2286/inetd tcp 0 0 0.0.0.0:111
0.0.0.0:* LISTEN 2812/rpcbind tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
5710/nginx tcp 0 0 0.0.0.0:22
0.0.0.0:* LISTEN 2560/sshd tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN
5710/nginx tcp6 0 0 :::111 :::*
LISTEN 2812/rpcbind unix 2 [ ACC ] STREAM
LISTENING 323648 6574/tmux /tmp//tmux-1000/default
unix 2 [ ACC ] STREAM LISTENING 619072
6790/fcgiwrap /var/run/fcgiwrap.socket unix 2 [ ACC ] SEQPACKET LISTENING 323 464/udevd
/run/udev/control unix 2 [ ACC ] STREAM LISTENING
610686 2812/rpcbind /var/run/rpcbind.sock unix 2 [ ACC ] STREAM LISTENING 318633 4785/mysqld
/var/run/mysqld/mysqld.sock

Each time I modify the nginx.conf file, I make sure to relaunch this command

nginx -t && nginx -s reload && echo "nginx configuration reloaded"

and same thing for php5-fpm

/etc/init.d/php5-fpm restart

Thanks for your help :-)

Pothi Kalimuthu
  • 6,117
  • 2
  • 26
  • 38
jmfayard
  • 31
  • 2
  • 7
  • Sources that didn't help - http://serverfault.com/questions/406158/nginx-php5-fpm-file-not-found - http://wiki.nginx.org/Pitfalls - http://wiki.nginx.org/IfIsEvil - https://gist.github.com/internaciulo/7172230 - http://kemovitra.blogspot.fr/2013/10/enabling-status-page-for-php5-fpm.html – jmfayard Oct 26 '13 at 21:52
  • all you posted here looks okay to me. What does your config for the fpm pool look like? Do you chroot it into some directory? – etagenklo Oct 26 '13 at 22:05
  • What script are you trying to run, and where did you put it in your filesystem? – Michael Hampton Oct 26 '13 at 22:21
  • @etagenklo thanks. I didn't do anything special for the fpm pool. I've just put [my /etc/php5/fpm/pool.d/www.conf](https://gist.github.com/internaciulo/7175247) on github – jmfayard Oct 26 '13 at 22:24
  • @MichaelHampton I put them in a non-standard directory in /srv/data1/test they are simpe php files that call phpinfo() for example. Before I wanted to run Dokuwiki and Dotclear. – jmfayard Oct 26 '13 at 22:25
  • 1
    get rid of this: `chroot = /var/www` – etagenklo Oct 27 '13 at 05:16
  • Wow, that whas it. I don't know how I can express my gratitude :) I can't even approve your answer since comments do not count for reputation ;) – jmfayard Oct 27 '13 at 07:13
  • @etagenklo Make it an answer :) – Michael Hampton Oct 27 '13 at 15:11
  • Ok, I did that :) – etagenklo Oct 28 '13 at 01:35

1 Answers1

1

Get rid of the

chroot = /var/www

in your fpm-pool configuration. Otherwise php-fpm won't be able to access /srv.

etagenklo
  • 5,834
  • 1
  • 27
  • 32