【问题标题】:file put content and chmod文件放置内容和chmod
【发布时间】:2011-10-07 01:47:30
【问题描述】:

我正在使用 file_get_contents 和 file_put_contents 来读取文件并写入其他文件。这两个文件的文件权限都设置为 777,我的问题是: 有什么办法可以在 file_put_contents 之后将文件权限更改为 644 吗?

我正在使用 chmod('/usr/local/pem/vhosts/155030/webspace/httpdocs/filename', 0644);和 chmod('文件名', 0644);但两者都显示错误“警告:chmod():不允许操作...

【问题讨论】:

    标签: php chmod


    【解决方案1】:

    您只能对用户拥有的文件进行 chmod。假设您使用 PHP 作为模块运行 Apache,那么您的用户就是运行 Apache 的任何用户。您需要以 root 身份(或可选地以文件的当前所有者身份)执行 chown(从 shell),以便将它们切换到您的 Web 服务器的用户。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-09
      • 2022-11-28
      • 2013-07-11
      • 2015-10-20
      • 2017-11-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多