inversesoft123 Posted April 21, 2009 Share Posted April 21, 2009 I found that on some servers users or scripts can write into files without having universal write premissions 777. but on some servers 777 chmod must be there to write into file.. why like this? Is there any settings into cpanel or WHM to enable this stuff or this is based on PHP version.. please help thx is advance. Quote Link to comment https://forums.phpfreaks.com/topic/155001-php-file-write-permissions-how/ Share on other sites More sharing options...
taquitosensei Posted April 21, 2009 Share Posted April 21, 2009 777 is read/write/execute for everybody you can set user and group permissions also. You can do this in in cpanel's file manager. Right click on the folder and go to permissions. Set read/write/execute for user only then only the webuser which is what php runs under will be able to upload files. Quote Link to comment https://forums.phpfreaks.com/topic/155001-php-file-write-permissions-how/#findComment-815334 Share on other sites More sharing options...
inversesoft123 Posted April 21, 2009 Author Share Posted April 21, 2009 777 is read/write/execute for everybody you can set user and group permissions also. You can do this in in cpanel's file manager. Right click on the folder and go to permissions. Set read/write/execute for user only then only the webuser which is what php runs under will be able to upload files. ya agreed but on some servers we can upload files without assigning read write execute (777) to folder hows that ? Quote Link to comment https://forums.phpfreaks.com/topic/155001-php-file-write-permissions-how/#findComment-815339 Share on other sites More sharing options...
Yesideez Posted April 21, 2009 Share Posted April 21, 2009 I can only think of bad server set-up. Quote Link to comment https://forums.phpfreaks.com/topic/155001-php-file-write-permissions-how/#findComment-815340 Share on other sites More sharing options...
inversesoft123 Posted April 21, 2009 Author Share Posted April 21, 2009 I can only think of bad server set-up. ohhh.. Previously my websites ware hosted on HostICan VPS and my team uploaded thousands of files and folders and text databases without 777 and sites ware working fine. But now I moved to dedicated and there are lots of permission denies on site... I think we need to correct them manually. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/155001-php-file-write-permissions-how/#findComment-815342 Share on other sites More sharing options...
Daniel0 Posted April 21, 2009 Share Posted April 21, 2009 4 = r-- = read 2 = -w- = write 1 = --x = execute => 7 = 4+2+1 = rwx = read+write+execute 6 = 4+2 = rw- = read+write 5 = 4+1 = r-x = read+execute 3 = 2+1 = -wx = write+execute 0 = --- = no permissions x1x2x3 = owner, group, other -[---][---][---] | | | '----> other | | '---------> group | '--------------> owner '-----------------> other stuff I won't explain here => 664 = rw-rw-r-- = owner/group: read+write; other: read So if file.php has owner daniel and group apache and it has 664 then my my user and the group apache (which your webserver could use) can read and write to and from that file. Everybody else can only read. Each file and directory has an owner and a group, and each running process will have an owner and group. In order to be allowed to perform an operation (i.e. read, write or execute) the process will have to satisfy at least one of owner, group or other permission masks. There is also something called setuid and setgid. Say for instance that foo.sh is owned by root and has has setuid. Whenever this file is executed it'll now be run as root, even if the user running it isn't root. Same thing for setgid only with groups instead. Then there is "sticky bit" which, when set on directories, ensures that only the owner of a file will be able to move or delete that file. Why someone can or cannot write to a file depends on all the above. You can find more information in the man pages or using Google. Quote Link to comment https://forums.phpfreaks.com/topic/155001-php-file-write-permissions-how/#findComment-815366 Share on other sites More sharing options...
inversesoft123 Posted February 27, 2010 Author Share Posted February 27, 2010 There is no need to change permissions on suPHP enabled servers. after rebuilding apache my problem was solved Quote Link to comment https://forums.phpfreaks.com/topic/155001-php-file-write-permissions-how/#findComment-1018877 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.