server {
listen 8080;
server_name www.domainname.com;
location /static/ {
alias /root/mysite/blog/static/;
}
location / {
uwsgi_pass 127.0.0.1:8001;
include /etc/nginx/uwsgi_params;
}
}
$ python manage.py collectstatic
0 static files copied to '/root/mysite/blog/static', 69 unmodified.
# 文件权限没有问题
$ ll /root/mysite/blog/static
total 16
drwxrwxr-x 4 root root 4096 Oct 5 09:13 ./
drwxrwxr-x 6 root root 4096 Oct 5 15:28 ../
drwxrwxr-x 6 root root 4096 Oct 5 09:13 admin/
drwxrwxr-x 5 root root 4096 Oct 5 09:13 blog/
# mysite/settings.py中已经指定了下面两项,**collectstatic**也收集成功,所以我觉得配置可能不存在问题
# 而且项目在本地能够运行,就是迁移到阿里云后无法运行了,所以是不是可能是阿里云的权限问题。
STATIC_URL="/static/"
STATIC_ROOT = os.path.join(BASE_DIR, 'blog/static')
怪我咯2017-05-16 17:15:48
alias /root/mysite/blog/static/;
/root
The directory is only accessible by root by default. No matter how open the files under it are, it’s useless if nginx can’t access them.
Website files are generally placed under /srv/http.
In addition, if you don’t want your server to be used as a broiler, attack others, send spam, or serve as a free proxy, don’t run web programs with root privileges.
阿神2017-05-16 17:15:48
I don’t know much about it, I just used Alibaba Cloud ECS server to build a blog