返回

file_put_contents failed to open stream: Permission denied in

发布时间:2022-10-14 02:04:21 359
# html# php# 服务器# 服务器

为什么file_put_contents failed to open stream: Permission denied in /home/user/public_html/test.php on line 2

写入的目录已经755权限了,还是写入失败。

最近项目迁移服务器,和file_put_contents 有关的都报错了,一般处理的话直接改成文件夹777权限。但是这个是存在安全问题的,虽然这样做很快、一下问题就解决了。但是这个问题的正确处理应该是这样。

问题原因:使用了错误用户!例如PHP用户和文件夹所有者不是一个 user.

解决办法:更改一致的用户即可;

You are probably using the wrong user.

Check if php uses the same user which owns the directory you are trying to write.

Php often uses wwwdata so if the directory is chmodded to 755 it means that the user created the directory can write it, but others can only read.

chown to the php user or chmod to 777.

 

file_put_contents failed to open stream: Permission denied in_php

 

若有帮助到您,欢迎点击推荐,您的支持是对我坚持最好的肯定(*^_^*)

你要保守你心,胜过保守一切。

作者:刘俊涛的博客

 

 

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像
精选文章
thumb 中国研究员首次曝光美国国安局顶级后门—“方程式组织”
thumb 俄乌线上战争,网络攻击弥漫着数字硝烟
thumb 从网络安全角度了解俄罗斯入侵乌克兰的相关事件时间线
下一篇
tp5怎么关联模型进行条件查询? 2022-10-14 01:34:38