简体   繁体   English

创建目录PHP时用户“没人”

[英]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.

相关问题 从PHP创建和写入文件(具有755权限)失败,因为PHP以“ nobody”身份运行并且目标文件所有者是另一个用户 - Creating & writing to a file (with permission 755) from PHP fails as PHP runs as 'nobody' and target file owner is another user 在PHP中创建新的Active Directory用户帐户时设置密码 - Set password when creating a new Active Directory user account in PHP 允许登录用户下载 PHP 中的文件,否则没有人不能 - Allow logged in user to Download File in PHP else nobody can't 以无人身份执行时,JAR写入文件的大小为零字节 - Jar write file zero byte sized when execute as nobody user 在活动目录上从PHP创建用户 - Creating user from php on active directory 使用PHP mkdir()创建用户组目录时要使用什么chmod权限 - What chmod permission to use when creating user group directory with PHP mkdir() Apache以nobody用户身份运行php脚本,cron以user用户身份运行php脚本 - Apache runs php scripts as user nobody, cron runs php scripts as user 没有用户的命名管道阻塞 - Named pipe blocking with user nobody 用户注册时如何建立目录(PHP) - How to make a directory when a user registers (PHP) 如何将PHP用户/组从Root | Root更改为Nobody | Nogroup? - How to change PHP-User/Group from Root|Root to Nobody|Nogroup?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM