nginx + django + uwsgi 安装配置

原创
2013/01/18 16:16
阅读数 638
安装uwsgi
推荐手动安装
cd uwsgi
python uwsgiconfig.py --build
cd nginx

cp uwsgi_params /usr/local/nginx/conf/


配置uwsgi
# /www/demo/wsgi_config.xml
<uwsgi>  
  <socket>127.0.0.1:8123</socket>
  <protocol>uwsgi</protocol>
  <processes>2</processes>
  <daemonize>/tmp/log/uwsgi/demo.log</daemonize>
  <listen>20</listen>  
  <master>true</master>  
  <module>demo.wsgi</module>
  <pythonpath>/www/demo</pythonpath>
  <profiler>true</profiler>  
  <memory-report>true</memory-report>  
  <enable-threads>true</enable-threads>  
  <logdate>true</logdate>  
  <limit-as>512</limit-as>  
</uwsgi>


配置nginx

修改vhost配置
server {
        listen       80;
        server_name  www.xxx.com;
        index index.html index.htm;
        root /www/demo;
        location / 
        {
                uwsgi_pass 127.0.0.1:8123;
                include uwsgi_params;
        }
 
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
                expires 30d;
        }
        location ~ .*\.(js|css)?$
        {
                expires 1h;
        }
        location /static
        {
                expires 1d;
        }
 
        include /xxx/server/nginx/conf/rewrite/default.conf;
        log_format easynow '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
        access_log /xxx/log/nginx/access/easynow.log easynow;

配置项目
# /www/demo/demo/settings.py
import os
import django.core.handlers.wsgi
 
os.environ['DJANGO_SETTINGS_MODULE'] = 'demo.settings'
application = django.core.handlers.wsgi.WSGIHandler()

运行
nginx -s reload
uwsgi -x wsgi_config.xml


展开阅读全文
打赏
0
3 收藏
分享
加载中
更多评论
打赏
0 评论
3 收藏
0
分享
返回顶部
顶部