Django报错,IOError: [Errno 13]Permission denied

来源:互联网 发布:after effects mac版 编辑:程序博客网 时间:2024/04/29 15:49

django部署环境

apache+mod_wsgi

报错代码

f = open(filename, "w")

分析

打印os.getcwd() # '/',得知当前工作目录是根目录,当然没有权限,原因是部署在apache的项目自己不会对工作目录进行初始化,要配置chroot

解决

在/etc/apache2中的具体的wsgi配置文件,增加以下配置即可
WSGIDaemonProcess [project_name] home="xxxx"
<Directory xxxx>
WSGIProcessGroup [project_name]
</Directory>

问题解决参考链接

  • http://modwsgi.readthedocs.io/en/latest/configuration-directives/WSGIDaemonProcess.html
  • https://stackoverflow.com/questions/12081789/pythons-working-directory-when-running-with-wsgi-and-apache
阅读全文
0 0
原创粉丝点击