
nginx を php-cgi とうまく連携させようとしていますが、思ったようには機能しません。動的ホスト名 (基本的には anything.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 はそれを理解できないため、代わりに絶対パスを使用するように調整しました。