【问题标题】:Permission Denied IOError权限被拒绝 IOError
【发布时间】:2014-12-11 23:45:15
【问题描述】:

我有一个 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']

【问题讨论】:

    标签: django apache python-2.7 django-forms


    【解决方案1】:

    使用 chmod 和显示的命令更改目录的权限。或更改您的目录。我不认为 /opt 是此类文件的最佳位置。 https://help.ubuntu.com/community/FilePermissions - 理解和使用文件权限

    【讨论】:

    • 谢谢,我想知道。我试图保存到 /test 但也没有用...
    猜你喜欢
    • 2011-06-11
    • 2013-05-02
    • 2017-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多