【发布时间】:2014-08-09 21:26:14
【问题描述】:
在管理界面中创建新记录时,尝试上传图片时出现以下错误。
Permission denied: '/home/jeffy/django_files/django_test/static/uploaded_files/1407616465_2016587_61DjIaZQI8L.jpg'
相关settings.py变量:
STATIC_ROOT = "/home/jeffy/django_files/django_test/static/"
MEDIA_ROOT=STATIC_ROOT
输出
ls -l /home/jeffy/django_files/django_test/static/
是
drwxrwxr-x 2 jeffy jeffy 4096 Aug 9 16:32 uploaded_files
服务器是以用户 jeffy 启动的:
jeffy@originaldjangster:/etc/nginx/sites-available$ sudo service nginx start
jeffy@originaldjangster:/etc/nginx/sites-available$ sudo /home/jeffy/django_files/django_test_venv/bin/gunicorn -c /home/jeffy/django_files/django_test_venv/gunicorn_config.py django_test.wsgi
root
我把这段代码放在settings.py的末尾
import getpass
print(getpass.getuser())
这就是为什么 gunicorn 服务器启动后“root”打印出来的原因。
为什么这个文件不能上传?
【问题讨论】:
标签: python django nginx gunicorn ubuntu-14.04