简体   繁体   中英

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?

PS. chmod -R 755 ...mypath/uploads doesn't work

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.

Use

umask(022);

in PHP before creating a file (eg line 1 in index.php). 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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