zoukankan      html  css  js  c++  java
  • file_put_contents failed to open stream: Permission denied in

    为什么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.

    文章来源:刘俊涛的博客欢迎关注公众号、留言、评论,一起学习。

     

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

  • 相关阅读:
    3.26
    3.25
    3.24
    3.23 JS学习
    3.22 团队作业1 疫情数据可视化
    3.19 个人作业1源码
    3.18 个人作业源码
    5.06python
    5.05Android
    5.04Android
  • 原文地址:https://www.cnblogs.com/lovebing/p/13186541.html
Copyright © 2011-2022 走看看