简体   繁体   English

PHP的文件权限问题

[英]File permission problems with PHP

I am trying to create a folder and fopen a file inside that folder. 我正在尝试创建一个文件夹,然后在该文件夹中fopen一个文件。

mkdir works fine for creating the folder (as the parent folder has 777 permission), but the resulting folder is owned by user id 99 while the script itself is running under cpanel with user id 32024. Now when I try to create a file inside this folder, I get: mkdir可以很好地用于创建文件夹(因为父文件夹具有777权限),但是当脚本本身在cpanel下以用户ID 32024运行时,生成的文件夹归用户ID 99拥有。现在,当我尝试在其中创建文件时文件夹,我得到:

SAFE MODE Restriction in effect. 安全模式限制生效。 The script whose uid is 32024 is not allowed to access /<path_of_file>/<folder_created_by_php> owned by uid 99 uid为32024的脚本不允许访问uid 99拥有的/ <path_of_file> / <folder_created_by_php>

This error is fully justifiable as I am trying to write to a folder owned by someone else but how can a script running under 32024 create a folder with owner as 99? 当我尝试写入别人拥有的文件夹时,此错误是完全合理的,但是在32024下运行的脚本如何创建所有者为99的文件夹? Anything wrong with the way server is behaving? 服务器的行为方式有问题吗? Any ideas? 有任何想法吗?

创建该文件后,您可以尝试将用户99和32024都包含在同一个组中,并使用chmod('yourfilename',0775)

Your problem is related to the safe mode setting on php: 您的问题与php上的安全模式设置有关:

Check this out for more information: http://www.serverschool.com/dedicated-servers/what-is-php-safe-mode/ You'll have all the information to understand what is safe mode actually... 请查看此以获取更多信息: http : //www.serverschool.com/dedicated-servers/what-is-php-safe-mode/您将拥有所有信息,以了解实际上是什么安全模式...

Just ask for your developers NOT to use safe_mode as it is a features unrecommended on all servers these days... 只是要求您的开发人员不要使用safe_mode,因为这是当今所有服务器上都不建议使用的功能...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM