location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
基本上只要在server裡加上這段就可以了,但要注意fastcgi參數一定要有SCRIPT_FILENAME,不然PHP會回傳空白頁面,這可以加在fastcgi_params或者location裡頭
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
直接用fastcgi.conf啊 {116}
另外可以參考ubuntu包的nginx.conf
裡面有正確回覆404頁面的相關敘述
@malsvent
conf.d裡面的嗎 {114}