PHP搭配chmod():不允许操作,safe_mode设置德precation参与? [英] PHP chmod( ):Operation not permitted, safe_mode deprecation involved?

查看:2491
本文介绍了PHP搭配chmod():不允许操作,safe_mode设置德precation参与?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我挣扎了一下,从PHP把握 CHMOD()的概念,因为我目前正在当然是有点过时,涉及safe_mode设置。它指出,作为safe_mode设置为关闭,限制修改为一个文件, CHMOD()权限当主人是不一样的一个执行命令被删除。我在一个场合使用PHP 5.5.9正在与XAMPP,我已验证标志被关闭(以防万一),但似乎无法得到它的工作。当我执行下面的PHP脚本:

I'm struggling a bit to grasp the concept of chmod() from PHP as the course I'm currently taking is a bit outdated and involves safe_mode. It states that as safe_mode is turned off, the restrictions to modify permissions with chmod() to a file when the owner is not the same as the one executing the command are removed. I'm working with PHP 5.5.9 in conjuncture with XAMPP, I've verified that the flags are turned off (just in case), but can't seem to get it working. As I execute the following PHP script:

echo "File permissions :" .  decoct(fileperms("file_permissions.php"));
chmod("file_permissions.php" ,0777);

我收到以下输出:

I receive the following output :

Warning: chmod(): Operation not permitted

我的文件权限以下

My permissions for the file are the following

-rwxrwxrwx@  1 joelhernandez  staff     24 Apr 14 06:59 file_permissions.php

和我已经执行的ps aux | grep的的httpd 来确认我的网络服务器可根据用户后台操作。

当我改变文件的所有权为后台

As I change the file ownership to daemon:

-rwxrwxrwx@  1 daemon  staff     24 Apr 14 06:59 file_permissions.php

一切正常,我不明白为什么,因为我的理解是,与safe_mode设置关闭,文件的所有权将意味着什么,而不是文件的权限是处理访问的方式。

Everything works, I do not understand why as I had understood that with safe_mode turned off, file ownership would mean nothing, instead file permissions were the way to handle access.

推荐答案

后台用户不是,所以,不允许改变由不同用户拥有的文件的模式。 PHP safe_mode设置是不是这里的原因。该警告是告诉你尝试的操作失败,因为Web服务器用户没有权限进行模式更改。

The daemon user is not root, so it is not allowed to change the mode of a file owned by a different user. PHP safe_mode is not the cause here. The warning is telling you that the attempted operation failed because the web server user did not have permission to make the mode change.

成功的操作,您手动更改文件的所有权后台,因为用户可以改变他们自己的文件的模式。

The operation succeeded after you manually changed the ownership of the file to daemon because users are allowed to change the mode of files they own.

这篇关于PHP搭配chmod():不允许操作,safe_mode设置德precation参与?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆