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

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; 
    } 
} 
主站蜘蛛池模板: 巢湖市| 遵义县| 义乌市| 新宾| 忻城县| 霞浦县| 昭苏县| 广昌县| 罗甸县| 浙江省| 龙里县| 越西县| 高阳县| 汝南县| 新龙县| 杭锦旗| 潍坊市| 广安市| 定边县| 舟曲县| 徐水县| 孙吴县| 九江市| 招远市| 上杭县| 五华县| 泾川县| 龙州县| 宜阳县| 滕州市| 潞城市| 城市| 绥芬河市| 蛟河市| 枣阳市| 新邵县| 固始县| 佛坪县| 镇原县| 攀枝花市| 仙游县|