I've spent hours figuring out how to install Nginx + Ruby Enterprise Edition + PHP5-fpm and MYSQL, finally it is all installed and all seems to have started fine.

But for some reason php files are not being processed.

.html files work fine, but when I try and view a .php file it appears as though it doesn't exist, even though it does. Interestingly, when I try and view a .html file that doesn't exist I get a nice Nginx 404 message, but when I view a .php file it doesn't even give me that.

So to my novice understanding, it looks like there's either something wrong with the config, or Nginx and PHP-fpm aren't talking to each other.

I've been looking at as many other examples of nginx config files and I'm sure that side of things is okay. Well... here's the relevant bit of the conf file anyway:

location ~ \.php$ {
   fastcgi_index index.php;
   fastcgi_param SCRIPT_FILENAME /var/www/eman/$fastcgi_script_name;
   include fastcgi_params;


    fastcgi_connect_timeout 60;
 fastcgi_send_timeout 180;
 fastcgi_read_timeout 180;
 fastcgi_buffer_size 128k;
 fastcgi_buffers 4 256k;
 fastcgi_busy_buffers_size 256k;
 fastcgi_temp_file_write_size 256k;
 fastcgi_intercept_errors on;

Any help is greatly appreciated.

edit: Here are the headers being returned from the test php file "http://eman.id.au/test.php":

HTTP/1.1 404 Not Found =>
Server => nginx/0.8.54
Date => Thu, 16 Dec 2010 19:30:30 GMT
Content-Type => text/html
Connection => close
X-Powered-By => PHP/5.3.2-1ubuntu4.5ppa5~lucid1

3 Answers 3


I believe I ran into exactly the same problem today, nginx does send the request to php-fpm (as indicated in the header) yet you get a 404, even though the file exists and has no (PHP/syntax) error at all, and no errors show up in any log (ngins or php-fpm).

You didn't include your full nginx config, but is it possible you don't have the option "root" define (correctly?) in your "server" section ? You need to make sure you do, that it points to the right location ofc and that it is inside the "server" section, not within a "location" one -- e.g:

server {
    root /var/www/eman;
    location ~ \.php$ {
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /var/www/eman/$fastcgi_script_name;
        include fastcgi_params;
  • I'm not certain, but that could have been the problem
    – Emmanuel
    Feb 6, 2011 at 1:17
  • I've ended up re-building the VPS and trying again using different tutorial, and now it's working fine. :)
    – Emmanuel
    Feb 6, 2011 at 1:26
  • This worked for me, and I was using a unix socket for the fastcgi_pass parameter
    – Sean
    Apr 19, 2015 at 2:16

If you take a look at the headers http://eman.id.au/test.php responds with then you'll see X-Powered-By: PHP/5.3.2-1ubuntu4.5ppa5~lucid1. It would not show this if the request was not passed to PHP. Also, if PHP cannot find the file path passed to it, it will echo the error No input file specified.

Since your site does output the powered by header and does not have the No input file specified. error the most likely reason is that you have an error in your PHP script and have display errors turned off. This results in a blank page and an entry in your error log, so have a look in there and see if it isn't filling up.

  • Ah, so it does!! I was viewing the page in google chrome and it was just giving me a 404 error, but I've just viewed it in firefox and it is just a blank page. There are no errors in the php script. In fact I've just taken all php out of it and the only content of it is a h1 tag
    – Emmanuel
    Dec 16, 2010 at 19:25
  • I've updated my original post with the http headers of the test.php file
    – Emmanuel
    Dec 16, 2010 at 19:41
  • And you are absolutely certain that your scripts are located in /var/www/eman/ and that the path and files are readable and executable by the PHP process? Dec 16, 2010 at 20:10
  • Yes they are the scripts are definitely in /var/www/eman/ the test.php file is in the same directory as index.html which works fine. What should I check to make sure they are readable and executable by the PHP process??? I'm not sure about that?
    – Emmanuel
    Dec 16, 2010 at 20:26
  • Well you spawn PHP in some way either via spawn-fcgi or php-fpm, the configuration file or command used to spawn should contain the user of the process, after that you'll have to check the linux permission for that user. Dec 16, 2010 at 20:50

Couple of thoughts:

   fastcgi_param SCRIPT_FILENAME /var/www/eman$fastcgi_script_name;

Does this need an extra slash

   fastcgi_param SCRIPT_FILENAME /var/www/eman/$fastcgi_script_name;

NGINX has a bit of a weird caching thing as well, so when you try the URL in your browser, add a ?random=12391 to the end to force a refresh. I've been puzzled for 30 minutes over a config only to find it was working all along but I was being tripped over by the cache.

You also probably want to escape your location a bit better (although this isn't causing this problem that you're having) It's better practice:

location ~ .php$


location ~ \.php$

.php$ would match a request such as yourpagephp rather than just yourpage.php

  • Okay, I've edited the conf files, but sill no luck...
    – Emmanuel
    Dec 16, 2010 at 11:14
  • The URL is: eman.id.au/test.php, eman.id.au itself works fine on index.html
    – Emmanuel
    Dec 16, 2010 at 11:15
  • The caching thing is not true, Nginx does not cache anything you do not specifically tell it to. It is NOT like Apache however, changes the the config file requires a reloading of the config file. Also your browser will cache requests, so that's what you might be confusing it with. Dec 16, 2010 at 12:18

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.