简体   繁体   English

Django-WSGI安装导致CentOS 7上的权限被拒绝问题

[英]Django-WSGI setup causing permission denied issues on CentOS 7

I'm new in the world of Django. 我是Django世界的新手。 I've been working on setting up WSGI to serve my Django project. 我一直在设置WSGI以服务于我的Django项目。 It is working fine on my personal machine but on the server I'm having a hard time to setup. 它在我的个人计算机上运行良好,但是在服务器上却很难设置。

I'm using logging in Django. 我正在使用Django中的日志记录。 But it is giving 'permission denied' error. 但是它给出了“权限被拒绝”错误。 But when I place all my log files in the '/tmp' folder, it works fine. 但是,当我将所有日志文件放在“ / tmp”文件夹中时,它可以正常工作。 Similar issue is with the 'db.sqlite3' file (that is my DB file which the Django uses). 'db.sqlite3'文件(这是Django使用的我的DB文件)也存在类似问题。

Please help me out in resolving the issue. 请帮助我解决问题。

Following information may be useful to help me out : 以下信息可能对您有所帮助:

OS : CentOS 7 Python : 2.7.5 Apache : 2.4.6 MOD_WSGI : 3.4 操作系统:CentOS 7 Python:2.7.5 Apache:2.4.6 MOD_WSGI:3.4

Following is the WSGI's error_log: 以下是WSGI的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'

You need to fix permissions with the chmod command, like this: 您需要使用chmod命令修复权限,如下所示:

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

If group is www-data ,change apache to www-data 如果组是www-data ,则将apache更改为www-data

If the security not matters.You can try 如果安全性不重要,可以尝试

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM