尽管具有777权限并且没有open_basedir值,但无法使用php写入/tmp
我正在尝试使用php fopen函数将文件写入我的/tmp目录(在apache服务器上),但是失败:
I'm trying to write a file to my /tmp directory (on an apache server) with the php fopen function, but it fails:
<?php
$handle = fopen("/tmp/test.txt", "x");
if ($handle)
echo "Success!";
else
print_r(error_get_last());
这将返回错误消息:
无法打开流:没有这样的文件或目录.
failed to open stream: No such file or directory.
/tmp
目录的权限设置为drwxrwxrwt
,我可以看到Web用户正在向其写入其他文件.奇怪的是,如果我将脚本指向具有权限777
的另一个文件夹,它将返回成功.但是我的open_basedir
没有任何价值.我有safe_mode=on
和allow_url_fopen=off
,但我认为不应该解释吗?
The /tmp
directory has permissions set to drwxrwxrwt
and I can see that the web user is writing other files to it. Mysteriously, if I point the script to another folder with permissions 777
, it returns success. But my open_basedir
has no value. I have safe_mode=on
and allow_url_fopen=off
, but I don't think that should explain it?
这是Apache Httpd 2.0上的PHP 5.3.10.
This is PHP 5.3.10 on Apache Httpd 2.0.
我遇到了完全相同的问题. PHP报告在/tmp/myoutputfile
中打开文件没有问题,但是该路径中没有文件.然后我做了
I had exactly the same problem. PHP reported no problem with opening file in /tmp/myoutputfile
, but no file was in that path. Then I did
find / -name "myoutputfile"
并在/tmp/systemd-…/myoutputfile
中找到它.
我在Google上找到了这篇文章.
因此,就我而言,这是Systemd和Apache Httpd的组合.我希望这会对某人有所帮助.
and found it in /tmp/systemd-…/myoutputfile
.
I've found this article on Google.
So, in my case, it was a Systemd and Apache Httpd combination. I hope this will help to someone.