2015-10-16 106 views
1

我有Django的1.6.11,阿帕奇2.4,mod_wsgi的,那里的日志处理程序没有权限写入日志文件有问题。我意识到有很多类似的问题,其中大部分都是通过正确设置文件权限来解决的。我相信权限设置是否正确在这种情况下,但会很乐意被证明是错误的...Django应用程序无法写入日志处理程序;权限被拒绝

从Apache日志+ ps,你可以看到Apache用户是apache

[Fri Oct 16 12:47:25.360845 2015] [:error] [pid 33075] [client XXX.XXX.XXX.XXX:64316] ValueError: Unable to configure handler 'custom': [Errno 13] Permission denied: '/var/www/producer/logs/producer2.log', referer: https://example.com/ 

[[email protected] producer] $ ps auxw | grep 33075 
apache 33075 0.8 0.3 445296 27668 ?  Sl 12:47 0:00 /usr/sbin/httpd -DFOREGROUND 
user  33230 0.0 0.0 112640 964 pts/2 R+ 12:47 0:00 grep --color=auto 33075 

但我的文件权限表明apache拥有目标文件,并具有读/写权限:

[[email protected] producer] $ ls -al logs 
total 4 
drwxrwxr-x. 2 apache apache 69 Oct 16 12:45 . 
drwxr-xr-x. 20 root root 4096 Oct 13 16:50 .. 
-rw-r--r--. 1 apache apache 0 Oct 16 12:45 producer2.log 
-rw-rw-r--. 1 apache apache 0 Oct 16 12:41 producer.log 
-rw-rw-r--. 1 apache apache 0 Oct 13 16:50 test_producer.log 
[[email protected] producer] $ pwd 
/var/www/producer 

更改权限777对日志文件没有帮助。

我的处理程序被配置为这样:

'handlers': { 
    'custom': { 
      'level': 'INFO', 
      'class': 'logging.handlers.RotatingFileHandler', 
      'filename': '/var/www/producer/logs/producer2.log', 
      'mode': 'a', 
      'maxBytes': 10000000, 
      'backupCount': 5, 
      'formatter': 'verbose' 
    }, 

我可以改变文件中处理程序指向其它地方,但无论在哪里,我点它,我如何更改目标文件/目录的权限,我收到了Permission denied错误。我记得有时你必须更改父目录的权限太多,但即使我设置到777和归apache,我得到了同样的错误。

我失去了一个愚蠢的一步的地方,或者有一个错字(这从一些新鲜的眼睛受益)?这个问题是否有其他可能的原因被掩盖?我与其他应用程序这样做之前,通常可以使用文件系统权限清除掉...

回答

1

好了,这样类型的随机解决方案,但事实证明我们的IT部门正在使用SELinux的管理内核级权限...忽略了我所做的任何事情。解决方案 - 与IT合作更新SELinux权限。

相关问题