Don't wanna be here? Send us removal request.
Text
django+uwsgi+nginx
1.虚拟环境的创建
pip install virtualenv
2.创建并启用虚拟环境
virtualenv -p python3 venv & source venv/bin/activate
3.安装django
pip install django==2.1.7
4.settings.py 设置
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
ALLOWED_HOSTS = ['*']
5.安装uwsgi
pip install uwsgi
6.uwsgi配置文件
[uwsgi]
socket = 127.0.0.1:8001
master = true
# vhost = true
# no-site = true
workers = 2
reload-mercy = 10
vacuum = true
max-requests = 1000
limit-as = 512
buffer-size = 30000
pidfile = uwsgi9090.pid
daemonize = uwsgi9090.log
7.安装nginx
apt-get install nginx
8.nginx 配置文件
server { listen 80; server_name localhost; location /static { alias /path/to/your/mysite/static; # your Django project's static files - amend as required } location / { include uwsgi_params; uwsgi_pass 127.0.0.1:9090; //必须和uwsgi中的设置一致 uwsgi_param UWSGI_SCRIPT demosite.wsgi; //入口文件,即wsgi.py相对于项目根目录的位置,“.”相当于一层目录 uwsgi_param UWSGI_CHDIR /demosite; //项目根目录 index index.html index.htm; client_max_body_size 35m; } }
9.静态资源
python manage.py collectstatic
10.修改/etc/nginx/nginx.conf
user root
11.运行
uwsgi --ini ddd.ini
service nginx restart
12.设置访问url 和 端口
13.浏览器访问
1 note
·
View note