nginx+fastcgi+flask的部署
官方的文檔是這樣子的
#!/usr/bin/python
from flup.server.fcgi import WSGIServer
from yourapplication import app
if __name__ == '__main__':
WSGIServer(application, bindAddress='/path/to/fcgi.sock').run()
location / { try_files $uri @yourapplication; }
location @yourapplication {
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_NAME "";
fastcgi_pass unix:/tmp/yourapplication-fcgi.sock;
}
官方文檔使用的是sock文件,若是想使用ip+端口的形式,也是能夠的。
#!/usr/bin/python
from flup.server.fcgi import WSGIServer
from yourapplication import app
if __name__ == '__main__':
WSGIServer(application, bindAddress=('127.0.0.1', 9000)).run()
# bindAddress是一個元組,第一個元素是用字串表示的ip地址,第二個元素是int類型的端口號。
location / { try_files $uri @yourapplication; }
location @yourapplication {
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_NAME "";
fastcgi_pass 127.0.0.1:9000;
}