nginx, php-cgi 및 "입력 파일이 지정되지 않았습니다."

nginx, php-cgi 및 "입력 파일이 지정되지 않았습니다."

나는 nginx가 php-cgi와 잘 작동하도록 노력하고 있지만 내가 원하는 대로 작동하지 않습니다. 나는 동적 호스트 이름을 허용하기 위해 몇 가지 설정 변수를 사용하고 있습니다. 기본적으로는 any.local입니다. 정적 파일에 제대로 액세스할 수 있기 때문에 작동하는 것으로 알고 있지만 PHP 파일은 작동하지 않습니다. "입력 파일이 지정되지 않았습니다."라는 표준이 표시됩니다. 파일이 존재하지 않을 때 일반적으로 발생하는 오류입니다. 그러나 동일한 경로의 정적 파일에 액세스할 수 있기 때문에 확실히 존재하고 경로가 정확합니다. 권한 문제일 수도 있지만 그것이 어떻게 문제가 될 수 있는지 잘 모르겠습니다. 나는 내 사용자 계정으로 Windows에서 이것을 실행하고 있으므로 php-cgi가 나에게 알리지 않고 다른 사용자로 실행되지 않는 한 권한이 있어야 한다고 생각합니다. >.>

내 구성은 다음과 같습니다.

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;
  }
 }
}

답변1

신경 쓰지 마세요. 알아 냈습니다.

Windows 버전의 nginx는 실행 파일 경로에 루트 경로를 추가하므로 루트 경로가 C:\nginx에 있고 파일을 C:\www에 저장하려면 루트 경로에 대해 ../www를 수행해야 합니다. Nginx는 이상하게 변환된 경로를 PHP에 전달하지만 PHP는 이를 이해하지 못하므로 대신 절대 경로를 사용하도록 조정했습니다.

관련 정보