rubing Posted October 19, 2008 Share Posted October 19, 2008 I get a permission denied warning when trying to write a file to disk using fopen, however fopen is enabled. I think this comes down to permissions. My suid and guid for php is 1000, however my directories on my server are all owned by a user 4096. Do I have to create a common group for php and the user?? Alternatively making all folders readable and writeable seems insecure and dangerous. Quote Link to comment https://forums.phpfreaks.com/topic/129093-fopen-denied-permission/ Share on other sites More sharing options...
rubing Posted October 19, 2008 Author Share Posted October 19, 2008 sorry i had that backwards. php is running as a user with id: 1000. root id: 4096 shouldn't php run as root? Quote Link to comment https://forums.phpfreaks.com/topic/129093-fopen-denied-permission/#findComment-669228 Share on other sites More sharing options...
wildteen88 Posted October 19, 2008 Share Posted October 19, 2008 shouldn't php run as root? Definitely not! What you should do is only set the necessary permissions for the file(s) you're trying to read/write too. Something like CHMOD 0755 should do. Quote Link to comment https://forums.phpfreaks.com/topic/129093-fopen-denied-permission/#findComment-669233 Share on other sites More sharing options...
trq Posted October 19, 2008 Share Posted October 19, 2008 shouldn't php run as root? No, Apache starts as root but quickly switches to a non privelleged user. its this user which needs to be able to write to your directories / files. Seems a wierd setup if Apache is running as uid 1000, numbers that high are normally reserved for actual users. Oh, and roots id is always 1. Quote Link to comment https://forums.phpfreaks.com/topic/129093-fopen-denied-permission/#findComment-669234 Share on other sites More sharing options...
rubing Posted October 19, 2008 Author Share Posted October 19, 2008 sorry i got it a little backwards....here is my user info: uid=1000(bob) gid=1000(bob) groups=1000(bob) and php gives the same uid=1000, gid=1000 the directory i am trying to write to is listed as follows: drwxr-xr-x 2 bob bob 4096 Oct 19 00:43 played ,so there really shouldn't be a problem, right?? However I get the following error: Warning: fopen(../public/played/e_santiago.mp3) [function.fopen]: failed to open stream: Permission denied in /home/bob/public_html/citymusicnow.com/private/lib_php/merge_mp3.inc on line 481 Quote Link to comment https://forums.phpfreaks.com/topic/129093-fopen-denied-permission/#findComment-669238 Share on other sites More sharing options...
rubing Posted October 20, 2008 Author Share Posted October 20, 2008 If i set the permissions to 777 it works of, but still gives me a permission denied message for 755. ??? Quote Link to comment https://forums.phpfreaks.com/topic/129093-fopen-denied-permission/#findComment-669625 Share on other sites More sharing options...
corbin Posted October 20, 2008 Share Posted October 20, 2008 755 means: rwx rx rx You could use 766. rwx rw rw Quote Link to comment https://forums.phpfreaks.com/topic/129093-fopen-denied-permission/#findComment-669632 Share on other sites More sharing options...
rubing Posted October 20, 2008 Author Share Posted October 20, 2008 yeah, but it seems to me that it should work if is set permissions as 700, b/c php is running with user id = 1000, the same as my user id. Since the folder is owned by my user, there shoudn't be a problem...yet there is? Quote Link to comment https://forums.phpfreaks.com/topic/129093-fopen-denied-permission/#findComment-669637 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.