在新创建的目录上设置了错误的权限
Wrong permissions set on newly created directory
这是创建具有错误权限的 "cache" 文件夹的代码:
mkdir($saveFolder, 02775);
当我使用 ls -la
检查文件夹权限时,我收到:
drwxr-sr-x
但我期待的是:
drwxrwsr-x
出于某些不明确的原因(至少对我而言)将代码更改为
mkdir($saveFolder);
chmod($saveFolder, 02775);
解决了问题。
现在我在文件夹上设置了正确的权限:
drwxrwsr-x
您当前的 umask 也会影响模式,因此根据您的 umask 设置,创建目录的模式可能与您在函数调用中指定的八进制不匹配。 http://php.net/manual/en/function.mkdir.php:
The mode is 0777 by default, which means the widest possible access. For more information on modes, read the details on the chmod() page. Note that you probably want to specify the mode as an octal number, which means it should have a leading zero. The mode is also modified by the current umask, which you can change using umask().
尝试设置 umask(0)
,提供给 mkdir()
的参数应该会按预期工作。
这是创建具有错误权限的 "cache" 文件夹的代码:
mkdir($saveFolder, 02775);
当我使用 ls -la
检查文件夹权限时,我收到:
drwxr-sr-x
但我期待的是:
drwxrwsr-x
出于某些不明确的原因(至少对我而言)将代码更改为
mkdir($saveFolder);
chmod($saveFolder, 02775);
解决了问题。
现在我在文件夹上设置了正确的权限:
drwxrwsr-x
您当前的 umask 也会影响模式,因此根据您的 umask 设置,创建目录的模式可能与您在函数调用中指定的八进制不匹配。 http://php.net/manual/en/function.mkdir.php:
The mode is 0777 by default, which means the widest possible access. For more information on modes, read the details on the chmod() page. Note that you probably want to specify the mode as an octal number, which means it should have a leading zero. The mode is also modified by the current umask, which you can change using umask().
尝试设置 umask(0)
,提供给 mkdir()
的参数应该会按预期工作。