Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to get nginx to play nice with php-cgi, but it's not quite working how I'd like. I'm using some set variables to allow for dynamic host names--basically anything.local. I know that stuff is working because I can access static files properly, however php files don't work. I get the standard "No input file specified." error which normally occurs when the file doesn't exist, but it definitely does exist and the path is correct because I can access the static files in the same path. It could possibly be a permissions thing, but I'm not sure how that could be an issue. I'm running this on Windows under my own user account, so I think it should have permission unless php-cgi is running under a different user without me telling it to. >.>

Here's my config;

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;
 gzip  on;

 server {
  # Listen for HTTP
  listen 80;

  # Match to local host names.
  server_name  *.local;

  # We need to store a "cleaned" host.
  set $no_www $host;
  set $no_local $host;

  # Strip out www.
  if ($host ~* www\.(.*)) {
   set $no_www $1;
   rewrite ^(.*)$ $scheme://$no_www$1 permanent;
  }

  # Strip local for directory names.
  if ($no_www ~* (.*)\.local) {
   set $no_local $1;
  }

  # Define default path handler.
  location / {
   root   ../Users/Stephen/Documents/Work/$no_local.com/hosts/main/docs;
   index  index.php index.html index.htm;

   # Route non-existent paths through Kohana system router.
   try_files $uri $uri/ /index.php?kohana_uri=$request_uri;
  }

  # pass PHP scripts to FastCGI server listening on 127.0.0.1:9000
  location ~ \.php$ {
   root   ../Users/Stephen/Documents/Work/$no_local.com/hosts/main/docs;
   fastcgi_pass   127.0.0.1:9000;
   fastcgi_index  index.php;
   include        fastcgi.conf;
  }

  # Prevent access to system files.
  location ~ /\. {
   return 404;
  }
  location ~* ^/(modules|application|system) {
   return 404;
  }
 }
}
share|improve this question

1 Answer 1

up vote 0 down vote accepted

Nevermind, I figured it out.

The Windows version of nginx appends the root path to the executable path, so if it's located at C:\nginx and you want to store your files in C:\www you need to do ../www for the root path. Nginx passes it's odd transformed path to PHP, but PHP doesn't understand it, so I adjusted it to use an absolute path instead.

share|improve this answer

Your Answer

 
discard

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.