配置如下:
location ~ .php$
{
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/wwwroot/test.com$fastcgi_script_name;
}
fastcgi_pass 用來指定php-fpm監聽的位址或者socket
curl -x127.0.0.1:80 test.com/lsx/1.php -I //當fastcgi_pass寫錯時。
HTTP/1.1 502 Bad Gateway
排查:
ls /tmp/ //看sock存在不存在
1.log ks-script-atWHvM php-fcgi.sock
2.vi /usr/local/php-fpm/etc/php-fpm.conf //看定義的sock是什麼
3.vi /usr/local/nginx/conf/nginx.conf //位址是否寫對
/data/wwwroot/test.com和站點根目錄一緻
如果監聽的是sock檔案。沒有定義
listen.mode = 666
檔案權限預設660。屬主為root,當nginx去讀的時候會提示沒有權限。狀态資訊502錯誤。
502錯誤。還有php-fpm程序耗盡了
本文轉自 蝦米的春天 51CTO部落格,原文連結:http://blog.51cto.com/lsxme/2057651,如需轉載請自行聯系原作者