Django-WSGI setup causing permission denied issues on CentOS 7

做~自己de王妃 提交于 2019-12-24 22:14:26

问题


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.

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).

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

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'

回答1:


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

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


来源:https://stackoverflow.com/questions/31809786/django-wsgi-setup-causing-permission-denied-issues-on-centos-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!