发布网友 发布时间:2022-04-22 09:57
共1个回答
热心网友 时间:2022-04-07 09:04
ubuntu django nginx负载均衡配置好了怎么用
1、安装uwsgi、flup、django
2、项目创建和配置
2.1、创建项目
cd /root/codes/
django-admin.py startproject myproject
2.2、创建/root/codes/uwsgi.xml
<uwsgi>
<socket>0.0.0.0:8001</socket>
<pythonpath>/root/codes/myproject</pythonpath>
<mole>django_wsgi</mole>
<profiler>true</profiler>
<memory-report>true</memory-report>
<enable-threads>true</enable-threads>
<logdate>true</logdate>
<limit-as>6048</limit-as>
</uwsgi>
2.3、创建/root/codes/django_wsgi
import os
import django.core.handlers.wsgi
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings' #"项目名.settings"
application = django.core.handlers.wsgi.WSGIHandler()
2.5、nginx 配置
可以直接修改/etc/nginx/nginx.conf或者在conf.d中添加一个conf后缀的文件,配置如下:
location ~ /zhaoshihui {
#include uwsgi_params;
#uwsgi_pass 127.0.0.1:8001;
fastcgi_pass 127.0.0.1:8001;
root /root/codes/zhaoshihui/;
}