一. 安装nginx
1. yum -y install wget
2.rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
3.yum install nginx
4.systemctl enable nginx.service
5.unzip安装:yum install unzip
2. pip 安装
https://bootstrap.pypa.io/get-pip.py
获得后执行:python get-pip.py
3. 虚拟环境pip install virtualenv
启用该虚拟环境:virtualenv venv
venv名字可变(可区分)
source venv/bin/activate
加入包
pip install flask
推出虚拟环境:deactivate
配置文件:
service nginx restart不靠谱
用:
nginx -s stop
nginx -c nginx.conf
前端后端文件夹的权限一定要设置成777,rootroot
4. uwsgi:
依赖包:yum install python-devel
yum -y install python-devel python-setuptools libxml2-devel
pip install uwsgi
5. nginx 配置
1.查看nginx配置文件位置:nginx -t
2.在nginx的配置文件server中加入:
listen 80;
server_name localhost;
location / {
root /home/flask_project/;
index index.html index.htm;
include uwsgi_params;
uwsgi_pass 127.0.0.1:3031;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/flask_project/;
}
3.uwsgi app_config.ini启动
4.pyc文件删除
5.nginx重启
service nginx restart
nohup uwsgi app_config.ini &
安装killall
yum install psmisc
6.killall -9 uwsgi关闭uwsgi