在fedora 21上{php} fopen错误

时间:2015-06-08 16:06:12

标签: php apache fopen fedora-21

我在阅读文件时获得以下权限警告:

PHP Warning: fopen(todo.txt): failed to open stream: Permission denied in /var/www/php/oauth/web/insert.php on line 26, referer: https://oauth.dev/dropbox_finish.php?state=5

这个问题来自于执行此代码:

try{
   $f = fopen("todo.txt", "r+");
...
}

我已经使用权限做了很多事情,让我展示当前的权限,然后我会展示其余部分。

[root@windows8 abel]# ls -lah /var/www/php
total 32K
drwxr-xr-x. 8 abel apache 4.0K Jun  3 15:53 .
drwxr-xr-x. 6 root root   4.0K May 29 12:38 ..
drwxr-xr-x. 3 abel abel   4.0K May 25 11:38 backup
drwxr-xr--. 6 abel apache 4.0K May 28 16:00 oauth
drwxr-xr-x. 8 abel apache 4.0K Apr 16 16:22 teamerp
drwxrwxr-x. 2 abel abel   4.0K Apr 16 17:18 TeamERP
drwx------. 5 abel abel   4.0K Apr 27 17:14 wordpress
drwx------. 6 abel abel   4.0K Jun  3 15:55 wp-test
[root@windows8 abel]# ls -lah /var/www/php/oauth/
total 36K
drwxr-xr--. 6 abel apache 4.0K May 28 16:00 .
drwxr-xr-x. 8 abel apache 4.0K Jun  3 15:53 ..
drwxr-xr--. 2 abel apache 4.0K Jun  7 11:56 app
-rwxr-xr--. 1 abel apache  124 May 25 16:05 composer.json
-rwxr-xr--. 1 abel apache 3.5K May 25 16:19 composer.lock
-rwxr-xr--. 1 abel apache    9 May 23 12:39 .gitignore
drwxrwxr-x. 3 abel apache 4.0K May 24 17:54 nbproject
drwxr-xr--. 5 abel apache 4.0K May 25 16:19 vendor
drwxr-xr--. 4 abel apache 4.0K Jun  8 15:16 web
[root@windows8 abel]# ls -lah /var/www/php/oauth/web/
total 36K
drwxr-xr--. 4 abel apache 4.0K Jun  8 15:16 .
drwxr-xr--. 6 abel apache 4.0K May 28 16:00 ..
drwxrwxr-x. 2 abel apache 4.0K May 28 16:00 css
-rw-rw-r--. 1 abel apache 5.4K Jun  8 17:37 dropbox_finish.php
-rwxr-xr--. 1 abel apache  109 May 28 09:59 index.php
-rw-rw-r--. 1 abel apache 1.3K Jun  8 17:50 insert.php
drwxrwxr-x. 2 abel apache 4.0K Jun  7 11:36 js
-rwxrwxrwx. 1 abel apache   55 Jun  8 17:50 todo.txt
[root@windows8 abel]# 

该文件为todo.txt。它具有777权限,网站可以正常工作,但该文件应该是开放的,可以编写它。如果apache正在服务的html和php文件,这是唯一的区别。

用户abelapache群组的成员。我还试图让用户apache拥有该文件并且它不起作用,除了apache可以读取其余的web文件,它只是这一个。 任何提示?

编辑:我创建了一个文件夹并将文件放入其中。运行以下内容:

echo substr(sprintf('%o', fileperms('todo/todo.txt')), -4);

结果是0777。我不知道发生了什么,php实际上看到了该文件,但我仍然收到错误。

EDIT2:我还执行以下命令以了解该文件是否是selinux问题。 semanage fcontext -a -t httpd_sys_rw_content_t /var/www/php/oauth/web/todo/todo.txt

没有结果。

0 个答案:

没有答案