84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
nginx+uwsgi+django1.5生产环境staticfiles如何配置?
使用manage.py collectstatics 将static文件拷贝到了STATIC_ROOT目录下,urls.py中需要添加r'static/$'路径吗?还需要怎么设置?
怎么设置能让nginx直接去处理这些css js文件?
ringa_lee
Post a section of the nginx configuration I am using now:
# 代码已加码,慎重copy server { listen 80; access_log /var/log/nginx/project_name_access.log; error_log /var/log/nginx/project_name_error.log; location / { proxy_pass http://127.0.0.1:8111; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $remote_addr; } location /static/ { alias /www/project_root/collectstatic/; } }
By the way, paste the push_static part in fabfile.py:
# 代码已加码,慎重copy from fabric.api import local local_project_root = '~/work/xxx' online_project_root = 'deployer@example.com:~/www/xxx' def push_static(): """Push static files to online.""" rsync = "rsync -avz --progress %s/collectstatic/ %s/collectstatic/" local('python manage.py collectstatic') local(rsync % (local_project_root, online_project_root))
Post a section of the nginx configuration I am using now:
By the way, paste the push_static part in fabfile.py: