简体   繁体   English

Ubuntu服务器文件夹权限

[英]Ubuntu server folder permissions

I have an uploads directory on my server, php upload works fine when folder's permission is set to 755 but if I make new dir inside uploads (uploads/subuploaddir) upload fails and I need to set 755 permission for this folder manually, so my question is how can I set 755 permission for uploads dir and all of it's future created sub directories? 我的服务器上有一个上载目录,当文件夹的权限设置为755时,php上载工作正常,但是如果我在上载(uploads / subuploaddir)内创建新目录,则上载失败,我需要手动为此文件夹设置755权限如何设置755上载目录及其将来创建的子目录的权限?

PS. PS。 chmod -R 755 ...mypath/uploads doesn't work chmod -R 755 ... mypath /上传不起作用

Thanks in advance. 提前致谢。 All answers are very appreciated. 非常感谢所有答案。 Peter 彼得

UPDATE: Problem solved, my fault. 更新:问题解决了,我的错。 PHP creates folders with permission 777 as default and I created folders for testing purposes through FTP manually, so it was created by another system user and with different permission. PHP创建的文件夹的默认权限为777,而我通过FTP手动创建了用于测试目的的文件夹,因此它是由另一个系统用户创建的,具有不同的权限。

Use 采用

umask(022);

in PHP before creating a file (eg line 1 in index.php). 在PHP中创建文件之前(例如index.php中的第1行)。 Using that option, every files that PHP creates will have a permission that equals to 755. If that doesn't work, search your code for calls to umask and change them to the one above. 使用该选项,PHP创建的每个文件都将具有等于755的权限。如果该权限不起作用,请在代码中搜索对umask调用,然后将其更改为上述代码。

您可以使用此命令chmod -R 755目录路径或文件

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

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