fileperms(): 统计失败,但文件存在
我正在使用 OpenVPN Web GUI,但我遇到了一些问题,因为该程序没有没有看到必要的文件之一。该文件的 ls -l </code> 如下:
-rw-r--r-- 1 root www 4153 Dec 20 10:12 /etc/openvpn/inn.crt
但是当我运行该程序时,它声称该文件不存在。我尝试了这个 sprintf('%d', fileperms($sLongFileName));
,它引发了“can't stat”警告。 file_exists()
也会返回 false。存在另一个 PHP 可见的文件:
-rw-r--r-- 1 root www 581 Dec 21 12:52 /etc/openvpn/crl.pem
这是什么原因?
编辑:我让程序对两个文件执行此操作:
file_put_contents("_dumpfile", "\n<<".$sLongFileName.">>\n", FILE_APPEND);
结果是这样的:
>>/etc/openvpn/inn.crt
<</etc/openvpn/crl.pem>>
文件路径是否存在问题?
I'm using the OpenVPN Web GUI and I'm having some problems because the program doesn't see one of the necessary files. The ls -l
for the file is as follows:
-rw-r--r-- 1 root www 4153 Dec 20 10:12 /etc/openvpn/inn.crt
But when I run the program, it claims that the file doesn't exist. I tried this sprintf('%d', fileperms($sLongFileName));
, which raises the "can't stat" warning. file_exists()
also returns false. There exists another file that's visible to PHP:
-rw-r--r-- 1 root www 581 Dec 21 12:52 /etc/openvpn/crl.pem
What's the cause of this?
EDIT: I had the program do this for both files:
file_put_contents("_dumpfile", "\n<<".$sLongFileName.">>\n", FILE_APPEND);
And the result is this:
>>/etc/openvpn/inn.crt
<</etc/openvpn/crl.pem>>
Is there some problem with the file path?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除了文件的物理存在之外,还有其他不同的因素可能会阻止您在特定用户下访问该文件。
您需要验证您的 PHP 脚本执行这些调用所使用的用户是否可以访问该文件以及该文件所在的目录(这取决于您的服务器和 PHP 配置)。所以首先找出用户名是哪个。
然后检查您的系统配置,如果 SELinux 等实用程序出于某种原因阻止对文件的访问,例如 webrequest 导致对不允许的文件进行文件访问。
Next to the physical existance of a file, there can be different other things that can prevent you from accessing the file under a specific user.
You need to verify if you can access the file and the directory the file is located with the user that is used by your PHP script to perform these calls (that depends on your server and PHP configuration). So first find out which is the username.
Then check your system configuration if utilities like SELinux are preventing access on files for a reason, e.g. webrequest results in file access on files it's not allowed to.