简体   繁体   English

Apache:0777目录上的权限被拒绝

[英]Apache: Permission denied on 0777 directory

I have shell script, that goes like: 我有外壳程序脚本,如下所示:

#!/bin/bash
( cd /var/qwebirc; ls .git; )

And PHP file that executes the script: 和执行脚本的PHP文件:

error_reporting(E_ALL);
exec("/var/qwebirc/pull.sh 2>&1", $arr);

Then when I call the shell script directly, I get the output I expect (ls of .git). 然后,当我直接调用shell脚本时,我得到了期望的输出(.git的ls)。 When I call the PHP script from CLI, I get the very same output. 当我从CLI调用PHP脚本时,会得到完全相同的输出。 But when the php script is called from browser, I get 但是,当从浏览器调用php脚本时,我得到了

ls: cannot open directory .git: Permission denied ls:无法打开目录。git:权限被拒绝

Okay, obviously permission problem of apache user. 好的,显然是apache用户的权限问题。 So I set 0777 to .git and all its files (for testing purposes). 所以我将0777设置为.git及其所有文件(出于测试目的)。 chown and chgrp to apache. chown和chgrp到Apache。 Changed the script like: 将脚本更改为:

( cd /var/qwebirc; pwd; whoami; ls -dl .git; ls .git; )

But the output in browser is still: 但是浏览器中的输出仍然是:

[0] => /var/qwebirc
[1] => apache
[2] => drwxrwxrwx. 8 apache apache 4096 Mar  1 03:59 .git
[3] => ls: cannot open directory .git: Permission denied

Which doesn't make much sense to me. 这对我来说没有多大意义。 Any idea what's the problem? 知道有什么问题吗? Thanks. 谢谢。

So the answer is SELinux. 因此答案是SELinux。 Not exactly sure how its policies work (gotta look into that now), but after disabling SELinux, ls from apache started to work. 不能完全确定其策略如何工作(现在必须对此进行研究),但是在禁用SELinux之后,来自Apache的ls开始起作用。

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

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