2011-11-15 14 views
1

私はNGINXには比較的新しいですが、私は(24時間以内)認めますが、基本的に設定しました。私は友人のためのサイトを設定しています。下のコードのようなサブドメインを使用するコードの例を見ました。しかし、サブドメインでは、PHPは動作しません。 "subdomain.domain.tld"に行くとファイルをダウンロードするように求められますが、 "subdomain.domain.tld/index.php"に行くと "入力ファイルが指定されていません"と表示されます。ところで、サブドメインはphpmyadminです。NGINX Config PHPのトラブル

server { 
    listen 80; 
    server_name irc.physibots.info; 

    rewrite (.*)  http://physibots.info:3989; 
} 

server { 
    listen 80; 
    server_name "~^([a-z]+)?.physibots.info"; 

    root /home/virtual/physibots.info/subdomains/$1; 
    index index.php index.html index.html; 

    location/{ 
     autoindex on; 
    } 
    location ~ \.php { 
     try_files $uri /error.html 
     fastcgi_index index.php; 
     fastcgi_pass unix:/tmp/php.socket; 

     include fastcgi_params; 
     fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; 
     fastcgi_param PATH_INFO $fastcgi_path_info; 
     fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    } 
} 

#server { 
# listen   443; 
# server_name localhost; 
# 
# charset utf-8; 
# 
# ssl on; 
# ssl_certificate 

server { 
    listen  80; 
    server_name physibots.info default; 

    root   /home/virtual/physibots.info/public_html; 
     index index.php index.html index.html; 

    location/{ 
     autoindex on; 
    } 
    location ~ \.php { 
     try_files $uri /error.html 
     fastcgi_index index.php; 
     fastcgi_pass unix:/tmp/php.socket; 

     include fastcgi_params; 
      fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; 
     fastcgi_param PATH_INFO $fastcgi_path_info; 
     fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    } 
} 
+0

同じサブドメインから静的ファイルにアクセスしようとしましたか?静的なファイルがうまくいけば、問題はfastcgiの設定にあります。そうでなければ、それはnginxの設定にあります。それは知っておいて良かったでしょう:) – petermolnar

答えて

2

try_filesを自分の場所/ {}ブロックに移動し、try_files $ uri $ uri//index.phpに変更します。

location/{ 
     autoindex on; 
     try_files $uri $uri/ /index.php; 
    } 
    location ~ \.php { 
     fastcgi_index index.php; 
     fastcgi_pass unix:/tmp/php.socket; 

残りは初心者にとっては驚くほどよく見えます。 :)

また、ウェブブラウザではなくカールでテストしていることを確認してください。そうしないと、常にキャッシュに挑戦します。

+0

感謝!、私は完全に別の問題を抱えていましたが、ずっと! :) 私の問題は、私のPHPファイルがダウンロードされていたことでした。私はこの問題を解決しましたが、ブラウザがキャッシュしていたので、PHPファイルをダウンロードしていました。どうもありがとう! –

+0

完璧な答え、これは本当に助けになった – Joseph