简体   繁体   English

PHP-mkdir的默认用户是www-data,如何更改?

[英]PHP - mkdir default user is www-data, how to change?

I have a script PHP that to create a folder and some files in this folder. 我有一个脚本PHP,用于创建一个文件夹和该文件夹中的一些文件。 Ok, I can done easily with mkdir in PHP but the folder is owned by www-data it's weird user or group that I didn't log in. Because that so I can't modify this folder and files in this folder (delete). 好的,我可以在PHP中使用mkdir轻松完成,但是该文件夹归www-data所有,它是我未登录的奇怪用户或组。因此,我无法修改此文件夹和该文件夹中的文件(删除) 。

Could someone suggest me how to fix this? 有人可以建议我如何解决此问题吗? Can I create the folder by our current log in user? 我可以通过当前登录用户创建文件夹吗? It's a public folder for every users (should chmod 775 ). 它是每个用户的公用文件夹( chmod 775 )。 And this is created folders by PHP script and can have many folder so I dont't want to run sudo chmod all of theses folders every time a new folder is created! 而且这是由PHP脚本创建的文件夹,可以有很多文件夹,因此我不想每次创建新文件夹时都对所有这些文件夹运行sudo chmod!

Any folder created by any application running under the http server service will be owned by the user executing such application (or component of the application). 由在http服务器服务下运行的任何应用程序创建的任何文件夹都将由执行该应用程序(或应用程序组件)的用户拥有。 That being said, if you're running an Apache HTTP daemon which the child processes owner is the www-data user, any folder created by any php script will be owned by such user. 话虽这么说,如果您正在运行一个Apache HTTP守护进程,其子进程所有者是www-data用户,则任何php脚本创建的任何文件夹都将归该用户所有。

You'll not be able to chown() any FS entry to other user, since www-data doesn't have permissions to do so. 由于www-data没有权限,因此您无法将(FS)FS条目授予其他用户。 You can change it manually via command line with super user permissions (uid == 0) using the chown command line binary. 您可以使用chown命令行二进制文件通过具有超级用户权限(uid == 0)的命令行手动更改它。

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

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