回复:权限 - 谁是在服务器上执行的 PHP 脚本的所有者?
我无法理解 PHP 中的权限和所有权。我有一个 PHP 脚本,它将图像(由客户端上传)写入文件夹。除非我将该文件夹的权限设置为 777,否则该脚本将会失败。我认为由于该脚本是由服务器运行的,因此它应该只需要“所有者”权限?为什么我需要公共写入权限?组权限到底是什么?
I'm having trouble understanding permissions and ownership in PHP. I have a PHP script that writes images (uploaded by the client) to a folder. The script will fail unless I set the permissions of that folder to 777. I thought that since the script was being run by the server, it should only need 'owner' permissions? Why do I need public write permissions? And what exactly are group permissions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果 Web 服务器 UID(用户)与拥有该目录的 UID(用户)不同,则需要授予公共权限。如果您可以控制服务器,那么您有两个选择。
您运行自己的服务器还是由第三方提供托管?
You need to give public permissions in the case where the web server UID (user) is different from the UID (user) who owns the directory. If you have control over your server then you have 2 options.
Are you running your own server or is hosting provided by a third party?
这取决于谁在运行你的服务器(我假设你正在使用 apache httpd)。在 phpinfo() 中,您可以看到哪个用户正在运行您的服务器(搜索诸如用户/组之类的内容),如果您将文件夹的所有者设置为该用户并赋予其写入能力,那么它应该可以工作。
It depends on who is running your server (I am assuming you are using apache httpd). In phpinfo() you can see what user is running your server (search for something like User/Group) and if you set the owner of the folder to that user and give it write ability it should work.