FAQ

Page Discussion Edit History

RuHttpFcgiModule

(Redirected from NginxRuHttpFcgiModule)

Contents

[edit] ngx_http_fastcgi_module

袦芯写褍谢褜 ngx_http_fastcgi_module 锌芯蟹胁芯谢褟械褌 锌械褉械写邪胁邪褌褜 蟹邪锌褉芯褋褘 褍写邪谢褢薪薪芯屑褍 FastCGI-褋械褉胁械褉褍. 小芯写械褉卸邪薪懈械 袩褉懈屑械褉 泻芯薪褎懈谐褍褉邪褑懈懈

[edit] 袛懈褉械泻褌懈胁褘

  • [#fastcgi_index fastcgi_index]
  • [#fastcgi_hide_header fastcgi_hide_header]
  • [#fastcgi_intercept_errors fastcgi_intercept_errors]
  • [#fastcgi_param fastcgi_param]
  • [#fastcgi_pass fastcgi_pass]
  • [#fastcgi_pass_header fastcgi_pass_header]
  • [#fastcgi_redirect_errors fastcgi_redirect_errors]

袩邪褉邪屑械褌褉褘, 锌械褉械写邪胁邪械屑褘械 FastCGI-褋械褉胁械褉褍 袙褋褌褉芯械薪薪邪褟 锌械褉械屑械薪薪邪褟 袩褉懈屑械褉 泻芯薪褎懈谐褍褉邪褑懈懈

: location / {
: fastcgi_pass   localhost:9000;
: fastcgi_index  index.php;

: fastcgi_param  SCRIPT_FILENAME  /home/www/scripts/php$fastcgi_script_name;
: fastcgi_param  QUERY_STRING     $query_string;
: fastcgi_param  REQUEST_METHOD   $request_method;
: fastcgi_param  CONTENT_TYPE     $content_type;
: fastcgi_param  CONTENT_LENGTH   $content_length;
: }

Template:Anchor

[edit] fastcgi_index

syntax: fastcgi_index 懈屑褟

default: 薪械褌

context: http, server, location

袛懈褉械泻褌懈胁邪 蟹邪写邪褢褌 懈屑褟 褎邪泄谢邪, 泻芯褌芯褉褘泄 锌褉懈 褋芯蟹写邪薪懈懈 锌械褉械屑械薪薪芯泄 $fastcgi_script_name 斜褍写械褌 写芯斜邪胁谢褟褌褜褋褟 锌芯褋谢械 URI, 械褋谢懈 URI 蟹邪泻邪薪褔懈胁邪械褌褋褟 褋谢褝褕芯屑.

Template:Anchor

[edit] fastcgi_hide_header

syntax: fastcgi_hide_header 懈屑褟

context: http, server, location

nginx 薪械 锌械褉械写邪褢褌 泻谢懈械薪褌褍 褋褌褉芯泻懈 蟹邪谐芯谢芯胁泻邪 "Status" 懈 "X-Accel-..." 懈蟹 芯褌胁械褌邪 FastCGI 褋械褉胁械褉邪. 袛懈褉械泻褌懈胁邪 fastcgi_hide_header 蟹邪写邪褢褌 写芯锌芯谢薪懈褌械谢褜薪褘械 褋褌褉芯泻懈. 袝褋谢懈 卸械 褋褌褉芯泻懈 薪褍卸薪芯 薪邪芯斜褉芯褌 褉邪蟹褉械褕懈褌褜, 褌芯 薪褍卸薪芯 胁芯褋锌芯谢褜蟹芯胁邪褌褜褋褟 写懈褉械泻褌懈胁芯泄 fastcgi_pass_header.

Template:Anchor

[edit] fastcgi_intercept_errors

syntax: fastcgi_intercept_errors on|off

default: fastcgi_intercept_errors off

context: http, server, location

袛懈褉械泻褌懈胁邪 芯锌褉械写械谢褟械褌, 锌械褉械写邪胁邪褌褜 谢懈 泻谢懈械薪褌褍 锌褉芯泻褋懈褉芯胁邪薪薪褘械 芯褌胁械褌褘 褋 泻芯写芯屑 斜芯谢褜褕械 懈谢懈 褉邪胁薪褘械 400 懈谢懈 卸械 锌械褉械薪邪锌褉邪胁谢褟褌褜 懈褏 薪邪 芯斜褉邪斜芯褌泻褍 nginx'褍 褋 锌芯屑芯褖褜褞 写懈褉械泻褌懈胁褘 error_page.

Template:Anchor

[edit] fastcgi_param

syntax: fastcgi_param 锌邪褉邪屑械褌褉 蟹薪邪褔械薪懈械

default: 薪械褌

context: http, server, location

袛懈褉械泻褌懈胁邪 蟹邪写邪褢褌 锌邪褉邪屑械褌褉, 泻芯褌芯褉褘泄 斜褍写褍褌 锌械褉械写邪胁邪褌褜褋褟 FastCGI-褋械褉胁械褉褍. 袙 泻邪褔械褋褌胁械 蟹薪邪褔械薪懈褟 屑芯卸薪芯 懈褋锌芯谢褜蟹芯胁邪褌褜 褌械泻褋褌, 锌械褉械屑械薪薪褘械 懈 懈褏 泻芯屑斜懈薪邪褑懈懈. 袛懈褉械泻褌懈胁褘 薪邪褋谢械写褍褞褌褋褟 褋 锌褉械写褘写褍褖械谐芯 褍褉芯胁薪褟 锌褉懈 褍褋谢芯胁懈懈, 褔褌芯 薪邪 写邪薪薪芯屑 褍褉芯胁薪械 薪械 芯锌懈褋邪薪褘 褋胁芯懈 写懈褉械泻褌懈胁褘 fastcgi_param.

袧懈卸械 锌褉懈胁械写褢薪 锌褉懈屑械褉 屑懈薪懈屑邪谢褜薪芯 薪械芯斜褏芯写懈屑褘褏 锌邪褉邪屑械褌褉芯胁 写谢褟 PHP:

: fastcgi_param  SCRIPT_FILENAME  /home/www/scripts/php$fastcgi_script_name;
: fastcgi_param  QUERY_STRING     $query_string;

袩邪褉邪屑械褌褉 SCRIPT_FILENAME 懈褋锌芯谢褜蟹褍械褌褋褟 胁 PHP 写谢褟 芯锌褉械写械谢械薪懈褟 懈屑械薪懈 褋泻褉懈锌褌邪, 邪 胁 锌邪褉邪屑械褌褉械 QUERY_STRING 锌械褉械写邪褞褌褋褟 锌邪褉邪屑械褌褉褘 蟹邪锌褉芯褋邪.

袝褋谢懈 褋泻褉懈锌褌褘 芯斜褉邪斜邪褌褘胁邪褞褌 蟹邪锌褉芯褋褘 POST, 褌芯 薪褍卸薪褘 械褖褢 褌褉懈 锌邪褉邪屑械褌褉邪:

: fastcgi_param  REQUEST_METHOD   $request_method;
: fastcgi_param  CONTENT_TYPE     $content_type;
: fastcgi_param  CONTENT_LENGTH   $content_length;

袝褋谢懈 PHP 斜褘谢 褋芯斜褉邪薪 褋 锌邪褉邪屑械褌褉芯屑 泻芯薪褎懈谐褍褉邪褑懈懈 --enable-force-cgi-redirect, 褌芯 薪褍卸薪芯 锌械褉械写邪胁邪褌褜 锌邪褉邪屑械褌褉 REDIRECT_STATUS 褋芯 蟹薪邪褔械薪懈械屑 "200":

: fastcgi_param  REDIRECT_STATUS  200;

Template:Anchor

[edit] fastcgi_pass

syntax: fastcgi_pass fastcgi-server

default: 薪械褌

context: location, if 胁 location

袛懈褉械泻褌懈胁邪 蟹邪写邪褢褌 锌芯褉褌 懈谢懈 褋芯泻械褌, 薪邪 泻芯褌芯褉芯屑 褋谢褍褕邪械褌 FastCGI-褋械褉胁械褉. 袩芯褉褌 屑芯卸械褌 斜褘褌褜 褍泻邪蟹邪薪 胁 胁懈写械 懈屑械薪懈 褏芯褋褌邪 懈谢懈 邪写褉械褋邪 懈 锌芯褉褌邪, 薪邪锌褉懈屑械褉,

: fastcgi_pass   localhost:9000;

邪 褋芯泻械褌 鈥 胁 胁懈写械 锌褍褌懈 unix 褋芯泻械褌邪:

: fastcgi_pass   unix:/tmp/fastcgi.socket;

Template:Anchor

[edit] fastcgi_pass_header

syntax: fastcgi_pass_header 懈屑褟

context: http, server, location

袛懈褉械泻褌懈胁邪 褉邪蟹褉械褕邪械褌 锌械褉械写邪胁邪褌褜 泻谢懈械薪褌褍 蟹邪锌褉械褖褢薪薪褘械 写谢褟 锌械褉械写邪褔懈 褋褌褉芯泻懈.

Template:Anchor

[edit] fastcgi_redirect_errors

syntax: fastcgi_redirect_errors on|off

袛懈褉械泻褌懈胁邪 锌械褉械懈屑械薪芯胁邪薪邪 胁 fastcgi_intercept_errors. 袩邪褉邪屑械褌褉褘, 锌械褉械写邪胁邪械屑褘械 FastCGI-褋械褉胁械褉褍

小褌褉芯泻懈 蟹邪谐芯谢芯胁泻邪 HTTP 蟹邪锌褉芯褋邪 锌械褉械写邪褞褌褋褟 FastCGI-褋械褉胁械褉褍 胁 胁懈写械 锌邪褉邪屑械褌褉芯胁. 袙 锌褉懈谢芯卸械薪懈褟褏 懈 褋泻褉懈锌褌邪褏, 蟹邪锌褍褖械薪薪褘褏 胁 胁懈写械 FastCGI-褋械褉胁械褉邪, 褝褌懈 锌邪褉邪屑械褌褉褘 芯斜褘褔薪芯 写芯褋褌褍锌薪褘 胁 胁懈写械 锌械褉械屑械薪薪褘褏 褋褉械写褘. 袧邪锌褉懈屑械褉, 褋褌褉芯泻邪 蟹邪谐芯谢芯胁泻邪 "User-Agent" 锌械褉械写邪褢褌褋褟 泻邪泻 锌邪褉邪屑械褌褉 HTTP_USER_AGENT. 袣褉芯屑械 褋褌褉芯泻 蟹邪谐芯谢芯胁泻邪 HTTP 蟹邪锌褉芯褋邪, 屑芯卸薪芯 锌械褉械写邪胁邪褌褜 锌褉芯懈蟹胁芯谢褜薪褘械 锌邪褉邪屑械褌褉褘 褋 锌芯屑芯褖褜褞 写懈褉械泻褌懈胁褘 fastcgi_param. 袙褋褌褉芯械薪薪邪褟 锌械褉械屑械薪薪邪褟

袙 屑芯写褍谢械 ngx_http_fastcgi_module 械褋褌褜 芯写薪邪 胁褋褌褉芯械薪薪邪褟 锌械褉械屑械薪薪邪褟, 泻芯褌芯褉褍褞 屑芯卸薪芯 懈褋锌芯谢褜蟹芯胁邪褌褜 写谢褟 褎芯褉屑懈褉芯胁邪薪懈褟 锌邪褉邪屑械褌褉芯胁 褋 锌芯屑芯褖褜褞 写懈褉械泻褌懈胁褘 fastcgi_param:

  • $fastcgi_script_name, 褝褌邪 锌械褉械屑械薪薪邪褟 褉邪胁薪邪 URI 蟹邪锌褉芯褋邪 懈谢懈 卸械, 械褋谢懈 URI 蟹邪泻邪薪褔懈胁邪械褌褋褟 褋谢褝褕芯屑, 褌芯 鈥 URI 蟹邪锌褉芯褋邪 锌谢褞褋 懈屑褟 懈薪写械泻褋薪芯谐芯 褎邪泄谢邪, 蟹邪写邪胁邪械屑芯谐芯 写懈褉械泻褌懈胁芯泄 fastcgi_index. 协褌褍 锌械褉械屑械薪薪褍褞 屑芯卸薪芯 懈褋锌芯谢褜蟹芯胁邪褌褜 写谢褟 蟹邪写邪薪懈褟 锌邪褉邪屑械褌褉邪 SCRIPT_FILENAME 懈 PATH_TRANSLATED, 懈褋锌芯谢褜蟹褍械屑褘褏, 胁 褔邪褋褌薪芯褋褌懈, 写谢褟 芯锌褉械写械谢械薪懈褟 懈屑械薪懈 褋泻褉懈锌褌邪 胁 PHP. 袧邪锌褉懈屑械褉, 写谢褟 蟹邪锌褉芯褋邪 "/info/" 懈 锌褉懈 懈褋锌芯谢褜蟹芯胁邪薪懈懈 写懈褉械泻褌懈胁
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/www/scripts/php$fastcgi_script_name;
锌邪褉邪屑械褌褉 SCRIPT_FILENAME 斜褍写褍褌 褉邪胁械薪 "/home/www/scripts/php/info/index.php".