本文介绍 nginx + anaconda + uwsgi + django 环境配置流程
pip 安装慢,解决方案
https://mirrors.tuna.tsinghua.edu.cn/help/pypi/
切换虚拟环境
conda activate <env_name>
安装 uWSGI
pip install uwsgi
在项目根目录
下创建 <uwsgi_oauth.ini> 配置文件
[uwsgi]
project = oauth
base = /root
# the base directory (full path)
chdir = %(base)/%(project)
# the virtualenv (full path)
home=%(base)/miniconda3/envs/%(project)
# Django's wsgi file
module = %(project).wsgi:application
wsgi.file=%(project)/wsgi_%(project).py
# localhost vschool环境
env = DJANGO_SETTINGS_MODULE=%(project).settings.vschool
# ecs
#env = DJANGO_SETTINGS_MODULE=%(project).settings.ecs
# process-related settings
# master
master = True
# maximum number of worker processes
processes=2
threads=4
socket=127.0.0.1:8003
#http=0.0.0.0:8003
pidfile=uwsgi_%(project).pid
#daemonize=/var/log/uswgi_%(project).log
daemonize=uswgi_%(project).log
#virtualenv=/root/miniconda3/envs/%(project)
配置nginx访问uwsgi<nginx_oauth.conf>
server {
listen 80;
server_name 121.40.187.161 open.namibox.com;
charset utf-8;
client_max_body_size 75M;
#location /media {
# alias /path/to/project/media;
#}
location /static {
alias /root/oauth/static;
}
location / {
uwsgi_pass 127.0.0.1:8003; # 与uwsgi中配置的相一致
include /etc/nginx/uwsgi_params;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
fastcgi_param HTTPS on;
}
location = /favicon.ico { access_log off; log_not_found off; }
}
网友评论