最近使用Nginx + PHP-fpm + Apache架設Vitger,遇到一個問題是當在做存檔或狀態變更時,網頁會跳出”您所做的變更為儲存”,當按下離開時,並不會儲存修改後的狀態,發現應該是Nginx設定上的問題,爬文很久終於找到解法,如下:
location ~ ^(?<SCRIPT>/.*\.(php|php3|phtml|suphp))$ { uninitialized_variable_warn off; set $fpm_url unix:/var/run/php-fpm.sock; if (-f /etc/php5/fpm/pool.d/$cur_php_user.conf) { set $fpm_url unix:/var/run/php-fpm/$cur_php_user.sock; } set $cur_php_user ""; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_NAME $SCRIPT; fastcgi_param SCRIPT_FILENAME $document_root$SCRIPT; fastcgi_pass $fpm_url; } location ~ ^(?<SCRIPT>/.*\.(php|php3|phtml|suphp))(?<PATH_INFO>.*)$ { uninitialized_variable_warn off; if ($PATH_INFO = "") { # avoid empty path_info set $PATH_INFO $SCRIPT; } set $fpm_url unix:/var/run/php-fpm.sock; if (-f /etc/php5/fpm/pool.d/$cur_php_user.conf) { set $fpm_url unix:/var/run/php-fpm/$cur_php_user.sock; } set $cur_php_user ""; fastcgi_index index.php; include fastcgi_params; fastcgi_param PATH_INFO $PATH_INFO; fastcgi_param PATH_TRANSLATED $document_root$PATH_INFO; fastcgi_param SCRIPT_NAME $SCRIPT; fastcgi_param SCRIPT_FILENAME $document_root$SCRIPT; fastcgi_pass $fpm_url; }