Answers
贴一段我现在在用的nginx配置吧:
# 代码已加码,慎重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/;
}
}
顺便贴一下fabfile.py里面,push_static部分:
# 代码已加码,慎重copy
from fabric.api import local
local_project_root = '~/work/xxx'
online_project_root = '[email protected]:~/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))
milkman
answered 10 years, 9 months ago