uwsgi - How to use nginx to associate django applications
漂亮男人
漂亮男人 2017-05-16 17:24:07
0
1
538

Django:1.6.5,python:2.6,centOS: 6.5,nginx:1.8.0-1

There are wsgi.py and prod.ini files under the django application

prod.ini file:

wsgi.py:

But how to associate it with nginx? I installed nginx through yum install nginx and modified the /etc/nginx/conf.d/myapp.conf file. The content is as follows:

How to configure it?

漂亮男人
漂亮男人

reply all(1)
滿天的星座

Change 9090 in /etc/nginx/conf.d/myapp.conf to 8000, and then change server 8000 to another port, such as port 80.

Then in order to display images, js, css, the following configuration is required

location /static/ {
    alias /home/www/MK_dream/MK_dream/static;
    if ($query_string) {
        expires max;
    }
    expires 30d;
}
location /static/media/ {
    alias /home/www/MK_dream/MK_dream/static/media;
    if ($query_string) {
        expires max;
    }
    expires 30d;
}

location ~* ^.+\.(cur|ico|json|gif|jpeg|cur|jpg|png|ttf|otf|js|css|mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi|wav|rtf|mpeg|woff)$ {
    root  /home/www/MK_dream/MK_dream/;
    expires 30d;
    access_log off;
}   

If the configuration is successful, it is recommended to use gunicorn替换uwsgi for better performance.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template