[英]user is “nobody” when creating directory PHP
I have the following code: 我有以下代码:
mkdir($thumb_dir)
which creates a directory in the proper location, but when I view the permissions it is 这会在正确的位置创建目录,但是当我查看权限时
Owner : nobody
Group : nobody
I don't have shell access to chown
. 我没有外壳访问
chown
。 How do I prevent the user assigned as nobody and how do I delete the folder that I have already made since I don't have permission. 如何防止被分配为“ nobody”的用户,以及如何删除由于没有权限而已经创建的文件夹。
It's a godaddy shared server... 这是一个Godaddy共享服务器...
you can delete empty directories with rmdir(). 您可以使用rmdir()删除空目录。
nobody is the user that runs the apache process. 没有人是运行apache进程的用户。 You can't change the owner from within php, nor you can delete the folder using shell access (or make any changes on it whatsoever) without root permissions;
您不能从php中更改所有者,也不能在没有root权限的情况下使用shell访问权限删除文件夹(或对其进行任何更改); you can manipulate it only through php
您只能通过php进行操作
This happens because the Web server is run by the nobody
user. 发生这种情况是因为Web服务器是由
nobody
用户运行的。 Therefore, everything you do on the file system will be done with the privileges of nobody
. 因此,您在文件系统上所做的一切将与特权来完成
nobody
。
There is typically no way for you to change anything about that. 通常,您无法更改任何内容。 You'll have to manage with the Apache user being different from the FTP user you have.
您必须使用与FTP用户不同的Apache用户进行管理。 If you create a directory with PHP, you'll only be able to delete it with PHP (using
rmdir()
when the directory is empty), and if you create files you will most likely have to delete them from PHP as well. 如果使用PHP创建目录,则只能使用PHP将其删除
rmdir()
如果目录为空,则使用rmdir()
),并且如果创建文件,则很可能也必须将其从PHP删除。
I suggest that you create your directory structure with your FTP user and keep as little PHP-generated content around as possible because of that. 我建议您使用FTP用户创建目录结构,并尽可能减少PHP生成的内容。
You can alleviate the symptoms using permissive authorizations (with chmod
), but that's generally not a super good idea security-wise. 您可以使用宽松的授权(使用
chmod
)缓解症状,但这通常不是安全的超级好主意。
Use rmdir($thumb_dir);
使用
rmdir($thumb_dir);
to delete it. 删除它。
You cannot change your PHP user on a shared server. 您不能在共享服务器上更改PHP用户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.