软件安装
安装git
安装mysql
安装redis
安装python
安装虚拟环境
安装uwsgi
安装nginx
步骤
前端发送的请求网址,向8000发请求被nginx捕获转发
部署步骤
# 本地收集static dist 上传
python manage.py collectstatic
# 拉项目
https://gitee.com/yqmc/t_api.git
# 切换(生成)虚拟环境
workon t_env
# 安装模块
pip3 install -r requirement.txt -i https://pypi.douban.com/simple
pip3 install uwsgi -i https://pypi.douban.com/simple
# uwsgi配置(配置在后面) 在项目根路径
vim t_api.xml
# nginx配置
cp /usr/local/nginx/conf/nginx.conf /home/back.conf
vim /usr/local/nginx/conf/nginx.conf
t_api.xml
<uwsgi>
<socket>127.0.0.1:8888</socket>
<chdir>/home/t_api</chdir>
<module>t_api.wsgi</module>
<processes>4</processes>
<daemonize>uwsgi.log</daemonize>
</uwsgi>
nginx.conf
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server {
listen 80;
server_name 127.0.0.1;
charset utf-8;
location / {
root /home/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
}
server {
listen 8000;
server_name 127.0.0.1;
charset utf-8;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8888;
uwsgi_param UWSGI_SCRIPT luffy_api.wsgi;
uwsgi_param UWSGI_CHDIR /home/project/luffy_api/;
}
location /static {
alias /home/static;
}
}
}
启动
nginx
uwsgi -x t_api.xml
杀死
pkill -9 -f nginx
pkill -9 -f uwsgi
过滤
ps -aux |grep nginx
ps -aux |grep uwsgi