我有一个Django应用程序,它将文件保存在/opt/Webapp/userfiles/
中,但Apache不允许这样做。
在我的设置文件中,我有:
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'userfiles')
但我也试过
MEDIA_ROOT = '/opt/Webapp/userfiles'
完整错误是:
IOError at /jobs/new
[Errno 13] Permission denied: u'/opt/Webapp/userfiles/770976f582c9a40152505b9e456bfd2d547ec9e7353c766f1c0e0e9a.py'
Request Method: POST
Request URL: https://10.5.1.133/jobs/new
Django Version: 1.7
Exception Type: IOError
Exception Value:
[Errno 13] Permission denied: u'/opt/Webapp/userfiles/770976f582c9a40152505b9e456bfd2d547ec9e7353c766f1c0e0e9a.py'
Exception Location: /opt/Webapp/jobs/views.py in upload, line 188
Python Executable: /usr/bin/python
Python Version: 2.7.6
Python Path:
['/opt/Webapp',
'/opt/.virtualenvs/smart/lib/python2.7/site-packages/django_admin_tools-0.5.1-py2.7.egg',
'/opt/.virtualenvs/smart/lib/python27.zip',
'/opt/.virtualenvs/smart/lib/python2.7',
'/opt/.virtualenvs/smart/lib/python2.7/plat-linux2',
'/opt/.virtualenvs/smart/lib/python2.7/lib-tk',
'/opt/.virtualenvs/smart/lib/python2.7/lib-old',
'/opt/.virtualenvs/smart/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7',
'/usr/local/lib/python2.7/plat-linux2',
'/usr/local/lib/python2.7/lib-tk',
'/opt/.virtualenvs/smart/lib/python2.7/site-packages']
答案 0 :(得分:0)
使用chmod和显示的命令更改目录的权限。或者更改您的目录。我不认为/ opt是这类文件的最佳位置。 https://help.ubuntu.com/community/FilePermissions - 了解和使用文件权限