PHP 和 CHMOD 问题
我希望我的 PHP 软件能够自动更新。为此,我需要 PHP 能够写入现有和不存在的文件(创建)。如果我只是将目标文件CHMOD为0777然后写入它总是有效吗?或者PHP/Apache/wtvr进程是否需要是文件的所有者?
有时,当人们使用 FTP 帐户上传时,所有者可能与 PHP 进程不同,这是一个问题吗?
编辑:我正在构建一个 PHP 应用程序,我不知道该应用程序将在哪些配置上运行,并且我无法修改任何服务器相关设置。我可以做 PHP 能做的事情,比如 chown()、chmod()。
I want my PHP software to be able to auto update. For this to work, I need PHP to be able to write into files both existing and non-existing (create). Will it always work if I just CHMOD the target files to be 0777 and then write into it? Or does the PHP/Apache/wtvr process need to be the owner of the file?
Sometimes when people upload using an FTP account, the owner might be different from the PHP process, is this a problem?
Edit: I'm building a PHP application, I can't know on which configurations the app will run on, and I can't modify any server related settings. I can do what PHP can do, like chown(), chmod().
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有一台服务器,当通过 FTP 上传文件时,文件的所有权会更改为 ftp 用户,这在过去导致了一些权限问题。
我们使用组来解决这个问题
,例如,您可以创建一个用户组来访问文件,并将 apache 和每个 ftp 用户添加到该组中:
然后您可以将文件/文件夹 chown 为用户 + 组,然后 chmod 为
775如果所有权更改为 ftp1.appUpdaters 或 ftp2.appUpdaters,其他用户仍然可以写入该文件。
就像我说的,我似乎不需要在我使用的所有服务器上都需要这个,所以我想你是否需要取决于你的服务器配置。如果您确实决定使用组,我发现此链接有时会派上用场
http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/
I have one server where, when files are uploaded through FTP, the ownership of the file changes to the ftp user which has caused a few permission problems in the past.
We use groups to get round this
For example, you could create a usergroup for accessing the files and add apache plus each of your ftp users to the group:
Then you can chown the file/folders to a user + group and chmod to 775
That way if the ownership changes to ftp1.appUpdaters or ftp2.appUpdaters, the other users can still write to the file.
Like I say, I don't seem to need this on all the servers I use so I guess whether you do or not depends on your server config. If you do decide to use groups tho, I find this link comes in handy sometimes
http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/
让您要上传到的文件夹归您的 www 服务器所有。然后,如果 chmodded 755,您的 php 脚本将能够写入该文件夹。
(不要在 www 拥有的 Web 文件中创建其他内容)。
Make the folder that you want to upload into owned by your www server. Then your php script will be able to write into that folder if it's chmodded 755.
(Don't make other stuff in your web files owned by www).