W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
FastCGI是在nginx,lighttpd和Cherokee等web服務(wù)器上的Flask應(yīng)用程序的另一個(gè)部署選項(xiàng)。
首先,您需要?jiǎng)?chuàng)建FastCGI服務(wù)器文件。讓我們稱之為yourapplication.fcgiC。
from flup.server.fcgi import WSGIServer
from yourapplication import app
if __name__ == '__main__':
WSGIServer(app).run()
nginx和舊版本的lighttpd需要顯式傳遞套接字以與FastCGI服務(wù)器通信。
為此,您需要將套接字的路徑傳遞到WSGIServer。
WSGIServer(application, bindAddress = '/path/to/fcgi.sock').run()
對(duì)于基本的Apache部署,您的.fcgi文件將出現(xiàn)在您的應(yīng)用程序URL中。例如:example.com/yourapplication.fcgi/hello/。有幾種方法可以配置您的應(yīng)用程序,以使yourapplication.fcgi不會(huì)出現(xiàn)在URL中。
<VirtualHost *>
ServerName example.com
ScriptAlias / /path/to/yourapplication.fcgi/
</VirtualHost>
lighttpd的基本配置如下所示:
fastcgi.server = ("/yourapplication.fcgi" => ((
"socket" => "/tmp/yourapplication-fcgi.sock",
"bin-path" => "/var/www/yourapplication/yourapplication.fcgi",
"check-local" => "disable",
"max-procs" => 1
)))
alias.url = (
"/static/" => "/path/to/your/static"
)
url.rewrite-once = (
"^(/static($|/.*))$" => "$1",
"^(/.*)$" => "/yourapplication.fcgi$1"
)
請(qǐng)記住啟用FastCGI,alias和rewrite模塊。此配置將應(yīng)用程序綁定到/yourapplication。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: