Flask+Nginx+uwsgi部署
阿新 • • 發佈:2017-12-18
.html nor var cal start thread roc main nod
- python安裝
- wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
- tar -zxvf Python-3.5.2.tgz
- 解壓cd Python-3.5.2
- yum update
- yum install openssl-devel -y
- ./configure
- make
- make install
- Nginx安裝
- yum install nginx
- python 虛擬環境創建
- python3 -m venv venv
- pip3 install flask
- Nginx全局配置文件
- cd /etc/nginx
- cp nginx.conf nginx.conf_bak
- vi nginx.conf
- user root;
- gzip on;
- 註釋sever{}
- cd /etc/nginx/conf.d
- vi mysite.conf
- server {
- listen 80;
- server_name 120.78.61.245;
- charset utf-8;
- access_log /var/log/nginx/log/mysite.access.log main;
- error_log /var/log/nginx/log/mysite.error.log warn;
- location / {
- root /var/www/mysite;
- index index.html index.htm;
- include uwsgi_params;
- uwsgi_pass 127.0.0.1:5000;
- uwsgi_param UWSGI_PYHOME /var/www/venv;
- uwsgi_param UWSGI_CHDIR /var/www/mysite;
- uwsgi_param PYTHONPATH /var/www/mysite;
- uwsgi_param UWSGI_MODULE run;
- uwsgi_param UWSGI_CALLABLE app;
- }
- }
- 安裝uwsgi
- pip3 install uwsgi
- cd /var/www/mysite/
- vi uwsgi.ini
- [uwsgi]
- socket = 127.0.0.1:5000 #註: 指定某個固定端口
- processes = 4 #註:跑幾個進程,這裏用4個進程
- threads = 2
- master = true
- pythonpath = /var/www/mysite
- module = run
- callable = app
- memory-report = true
- 啟動nginx
- cd /var/log/nginx
- mkdir log
- nginx -t -c /etc/nginx/nginx.conf
- systemctl start nginx.service
- 備註systemctl status nginx.service可以查看具體錯誤
- 啟動uwsgi(在venv下)
- cd /var/www/
- uwsgi --ini mysite/uwsgi.ini
Flask+Nginx+uwsgi部署