切换带有django环境
source xxx/bin/activate
安装 uwsgi 以及nginx
sudo pip3 install -i https://pypi.douban.com/simple/ uwsgi
如果报下面错误
执行
sudo apt-get install libpython3.9-dev
再执行 sudo pip3 install -i https://pypi.douban.com/simple/ uwsgi 即可
sudo apt-get install nginx
新建 xxx.ini
[uwsgi]
socket = 127.0.0.1:8091
chdir = /xxx/xxx/xxx/xxx (项目目录)
wsgi-file = /xxx/xxx/xxx/xxx/xxx/wsgi.py (项目wsgi目录)
master = true
processes = 4
buffer-size = 65536
chmod-socket = 664
vacuum = true
threads=100
daemonize = uwsgi.log
virtualenv = /xxxxx/xxx/bfvenv (Python环境)
编辑nginx.conf
如果 /etc/nginx/nginx.conf 中有 include /etc/nginx/conf.d/*.conf;
在 /etc/nginx/conf.d 目录下新建xxx.conf
server {
listen 80;
server_name xxxx; (有域名写域名,没有写IP)
charset utf-8;
access_log /var/log/nginx/myweb_access.log;
error_log /var/log/nginx/myweb_error.log;
location / {
uwsgi_pass 127.0.0.1:8091; (uwsgi 中的IP)
include uwsgi_params;
}
location /static {
alias /xxx/xxx/xxx/xxx/static; (项目中的static)
}
}
写完即可
执行
uwsgi --ini xxx.ini
sudo /usr/sbin/nginx