PHP无法读取具有读取权限的文件 [英] PHP can't read file with read permissions

查看:445
本文介绍了PHP无法读取具有读取权限的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有这些权限的文件(0644)

I have a file with these permissions (0644)

-rw-r--r-- 1 root root

因此,据我了解,任何人都可以读取该文件.

So from my understanding this file should be readable by anyone.

现在我有了以下代码:

file_get_contents('/path/to/file');

这给了我

警告:file_get_contents(...):无法打开流:权限在...中被拒绝

Warning: file_get_contents(...): failed to open stream: Permission denied in ...

我想念什么?

我正在从www-data下的Web服务器运行它.

I'm running it from a web server under www-data.

推荐答案

可能的原因与解决方案:

Possible causes with solutions:

解决方案:为整个文件夹层次结构配置正确的权限.另请参见此注释在PHP安全模式下.

Solution: Configure the correct permission rights for the whole folder hierarchy. Also see this remark on PHP safe mode.

这很奇怪,但是这种情况发生.

解决方案:配置文件和文件夹的执行权限.

Solution: Configure execution rights for file and folders.

解决方案:正确配置它们.

Solution: Configure them properly.

这篇关于PHP无法读取具有读取权限的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆