Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I get the above error when using nginx and php-cgi on Windows. This is my nginx configuration:

worker_processes 1;

events {
  worker_connections 1024;

http {
  include mime.types;
  default_type application/octet-stream;
  sendfile on;
  keepalive_timeout 65;

  server {
    listen 80 default;
    server_name localhost;
    charset utf-8;
    root ..\www;
    index index.php index.html index.htm;
    error_page 500 502 503 504 /50x.html;

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

    location ~ /\. {
      access_log off;
      log_not_found off;
      deny all;

    location / {

      if (!-e $request_filename) {
          rewrite ^/(.*)$ /index.php/$1 last;




Can anyone see anything wrong with it?

Edit: here's a request log. - - [30/Apr/2012:00:04:35 +0100] "GET /hi.php HTTP/1.1" 404 36 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120428 Firefox/15.0a1"
share|improve this question
Could you enable log and post a logged request? Also, while likely irrelevant, which version of Windows are you running this on? – Sašo Apr 29 '12 at 23:03
Added log to the question. And running Windows 7 Ultimate SP1 x64 – Alex Apr 29 '12 at 23:06
Eh, I just realized the request log doesn't tell much, error log would be better. Did you perhaps try using full path in the .php location for root? i.e. c:/nginx/www – Sašo Apr 29 '12 at 23:19
Nothing logs in the error file. And just tried your suggestion, now I get a nginx 404 page. – Alex Apr 29 '12 at 23:23

Please, read the documentation carefully

Paths in a configuration file must be specified in UNIX-style using forward slashes:

access_log   logs/site.log;
root         C:/web/html;
share|improve this answer

Try using forward slashes / instead of backslashes \ in your root directives.

Also, I don't think you need a root directive in your location ~ \.php$ { block.

share|improve this answer

Nothing logs in the error file. And just tried your suggestion, now I get a nginx 404 page.

  1. Remove "try_files $uri =404;" from "location ~ .php$ { }".
  2. Add "root c:/nginx/www;" (or right path) to "location / {}".
  3. "if (!-e $request_filename) {}" much better replace to try_files.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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