Nginx PHP-FPM 設定要點

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;

留言

  1. 直接用fastcgi.conf啊 {116}
    另外可以參考ubuntu包的nginx.conf
    裡面有正確回覆404頁面的相關敘述

粗體斜體刪除線連結引用圖片程式碼

注意:您的電子信箱將不會被公開,且網站連結不會被搜尋引擎採計

{124} {123} {122} {121} {120} {119} {118} {117} {116} {115} {114} {113} {112} {111} {100} {025} {024} {023} {022} {021} {020} {019} {018} {017} {016} {015} {014} {013} {012} {011} {010} {009} {008} {007} {006} {005} {004} {003} {002} {001}