Python3+Flask+uwsgi部署

python3

按照常規的方式安裝便可:html

wget https://www.python.org/ftp/python/3.5.4/Python-3.5.4.tgz
tar zxvf Python-3.5.4.tgz
cd Python-3.5.4/
./configure
make -j4
make install

添加環境變量python

vim /etc/profile
PYTHONPATH=/usr/local/lib/python3.5/bin

修改 yum 的pythonflask

vim /usr/bin/yum
#!/usr/bin/python -> #!/usr/bin/python2.7

Flask

pip3 install flask

uwsgi

wget https://pypi.python.org/packages/0c/1c/44849e293e367a157f1ad863cee02b4b865840543254d8fae3ecdebdbdb9/uwsgi-2.0.12.tar.gz

個人網頁的路徑爲:vim

/home/APIParse
/home/APIParse/htmlWeb.py
...

在當前路徑下新建uwsgiconfig.ini,寫入以下信息app

[uwsgi]
# htmlWeb.py文件所在目錄
chdir           = /home/APIParse

callable = app

# flask文件名
wsgi-file= htmlWeb.py

# 進程數
processes       = 5

# 使用3993端口
http = 0.0.0.0:3993

# 日誌輸出目錄
daemonize = /home/APIParse/flask.log

pidfile = project-master.pid

完成保存退出,啓動命令並查看進程:python2.7

# 啓動命令
uwsgi uwsgi.ini
 # 查看進程是否啓動成功
ps -ef | grep uwsgi

若是想要中止uwsgi,就能夠殺死全部:spa

killall -9 uwsgi
相關文章
相關標籤/搜索