Django-WSGI安装导致CentOS 7上的权限被拒绝问题 [英] Django-WSGI setup causing permission denied issues on CentOS 7

查看:129
本文介绍了Django-WSGI安装导致CentOS 7上的权限被拒绝问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Django世界的新手.我一直在设置WSGI以服务于我的Django项目.它在我的个人计算机上运行良好,但是在服务器上却很难设置.

I'm new in the world of Django. I've been working on setting up WSGI to serve my Django project. It is working fine on my personal machine but on the server I'm having a hard time to setup.

我正在使用Django中的日志记录.但是它给出了权限被拒绝"错误.但是,当我将所有日志文件放在"/tmp"文件夹中时,它可以正常工作. db.sqlite3文件(这是Django使用的我的DB文件)也存在类似的问题.

I'm using logging in Django. But it is giving 'permission denied' error. But when I place all my log files in the '/tmp' folder, it works fine. Similar issue is with the 'db.sqlite3' file (that is my DB file which the Django uses).

请帮助我解决问题.

以下信息可能对我有帮助:

Following information may be useful to help me out :

OS:CentOS 7 的Python:2.7.5 阿帕奇:2.4.6 MOD_WSGI:3.4

OS : CentOS 7 Python : 2.7.5 Apache : 2.4.6 MOD_WSGI : 3.4

以下是WSGI的error_log:

Following is the WSGI's error_log:

[Wed Aug 05 01:53:31.661156 2015] [:error] [pid 32177] [remote 192.168.40.142:184] Traceback (most recent call last):
[Wed Aug 05 01:53:31.661192 2015] [:error] [pid 32177] [remote 192.168.40.142:184]   File "/var/www/html/portals/wsgi.py", line 18, in <module>
[Wed Aug 05 01:53:31.661254 2015] [:error] [pid 32177] [remote 192.168.40.142:184]     application = get_wsgi_application()
[Wed Aug 05 01:53:31.661274 2015] [:error] [pid 32177] [remote 192.168.40.142:184]   File "/var/www/html/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Wed Aug 05 01:53:31.661313 2015] [:error] [pid 32177] [remote 192.168.40.142:184]     django.setup()
[Wed Aug 05 01:53:31.661330 2015] [:error] [pid 32177] [remote 192.168.40.142:184]   File "/var/www/html/venv/lib/python2.7/site-packages/django/__init__.py", line 17, in setup
[Wed Aug 05 01:53:31.661361 2015] [:error] [pid 32177] [remote 192.168.40.142:184]     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Wed Aug 05 01:53:31.661378 2015] [:error] [pid 32177] [remote 192.168.40.142:184]   File "/var/www/html/venv/lib/python2.7/site-packages/django/utils/log.py", line 86, in configure_logging
[Wed Aug 05 01:53:31.661451 2015] [:error] [pid 32177] [remote 192.168.40.142:184]     logging_config_func(logging_settings)
[Wed Aug 05 01:53:31.661483 2015] [:error] [pid 32177] [remote 192.168.40.142:184]   File "/usr/lib64/python2.7/logging/config.py", line 803, in dictConfig
[Wed Aug 05 01:53:31.661519 2015] [:error] [pid 32177] [remote 192.168.40.142:184]     dictConfigClass(config).configure()
[Wed Aug 05 01:53:31.661537 2015] [:error] [pid 32177] [remote 192.168.40.142:184]   File "/usr/lib64/python2.7/logging/config.py", line 585, in configure
[Wed Aug 05 01:53:31.661584 2015] [:error] [pid 32177] [remote 192.168.40.142:184]     '%r: %s' % (name, e))
[Wed Aug 05 01:53:31.661643 2015] [:error] [pid 32177] [remote 192.168.40.142:184] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/var/www/html/portals/logs/debug.log'

推荐答案

您需要使用chmod命令修复权限,如下所示:

You need to fix permissions with the chmod command, like this:

chmod 775 /var/www/html/portals/logs/debug.log
chown username:apache /var/www/html/portals/logs/debug.log

如果组为www-data,请将apache更改为www-data

If group is www-data,change apache to www-data

如果安全性无关紧要,您可以尝试

If the security not matters.You can try

chmod 777 /var/www/html/portals/logs/debug.log

这篇关于Django-WSGI安装导致CentOS 7上的权限被拒绝问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆