官术网_书友最值得收藏!

How to do it...

We'll now configure uWSGI to point to our Django project, which for this example I have located at /var/www/djangodemo. Here's the uwsgi.ini file:

[uwsgi] 
socket = 127.0.0.1:8000 
uid=www-data 
gid=www-data 
chdir=/var/www/djangodemo 
module=djangodemo.wsgi 
master=True 
pidfile=/tmp/uwsgi-djangodemo.pid 
vacuum=True 
max-requests=5000 
daemonize=/var/log/uwsgi/djangodemo.log 

For this example, we're also using TCP sockets rather than Unix sockets. Although they're slightly more efficient, having a proper socket makes it much easier for the initial testing phase. If you're hitting limitations (many thousands of concurrent connections), then I'd suggest that you use Unix sockets.

Now for the NGINX configuration, we'll use a separate configuration file (/etc/nginx/conf.d/django.conf) to keep things neat and tidy:

server { 
    listen       80; 
    server_name  djangodemo.nginxcookbook.com; 
 
    access_log  /var/log/nginx/djangodemo-access.log  combined; 
 
    location = /favicon.ico { access_log off; log_not_found off; } 
 
    location /static|/media { 
        root /var/www/djangodemo/; 
    } 
 
    location / { 
        include         uwsgi_params; 
        uwsgi_pass      127.0.0.1:8000; 
    } 
} 
主站蜘蛛池模板: 道孚县| 宜丰县| 新巴尔虎左旗| 孙吴县| 仪陇县| 岳普湖县| 麻江县| 镇坪县| 个旧市| 柘城县| 连平县| 泰顺县| 大名县| 渝北区| 和龙市| 奉化市| 尉犁县| 孝昌县| 乾安县| 昭觉县| 法库县| 泰安市| 郯城县| 乐亭县| 延长县| 全椒县| 客服| 沂南县| 富源县| 望都县| 建宁县| 汝城县| 千阳县| 彩票| 洪洞县| 紫金县| 浠水县| 江口县| 两当县| 西藏| 临洮县|