nginx.conf の設定もちゃんと行ったのに動かない。

こういうの結構ハマる、というか、今日ハマった。


環境:freebsd 9.1 amd64 + nginx-1.4.1,1 + php5-5.4.15


エラーログ

FastCGI sent in stderr: “Primary script unknown” while reading ~



そんなときに見落としがちな箇所


nginx.conf

 インストール後のデフォルト↓
 #location ~ \.php$ {
 #           root           html;
 #           fastcgi_pass   127.0.0.1:9000;
 #           fastcgi_index  index.php;
 #           fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
 #           include        fastcgi_params;
 #} 


これをこうする↓ (一例)
  location ~ \.php$ {
            root           /usr/local/www/nginx-dist;   ←ドキュメントルートに変更
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
 }   


*参考にしたサイトさん
nginx+php-fpmでPHPを動かす。その3