jotate Posted September 25, 2007 Share Posted September 25, 2007 I'm trying to get an open source PHP app working for my company. It's giving me the following custom error: FreeMED was unable to create a file to record the healthy status of the system. The FreeMED directory should be owned by the user that the webserver is running as... Usually this is 'apache'. You can also fix this by giving universal write access to the home directory of FreeMED. But that is not advisable from a security standpoint. I've narrowed it down to the line of PHP that's breaking it here: $test = CreateObject('FreeMED.FreeMEDSelfTest'); As far as I can tell, I've made the directory it's using as open as possible and it's still giving me that error. The owner is apache (user and group) and the permissions are (temporarily) set at 0777 (universal read/write). Is there some PHP or Apache configuration that needs changed to allow PHP this kind of permission? Quote Link to comment https://forums.phpfreaks.com/topic/70653-file-write-permissions/ Share on other sites More sharing options...
jotate Posted September 25, 2007 Author Share Posted September 25, 2007 Update, created a test.php: <?php $filename = "testFile.txt"; $filehandler = fopen($filename, 'w') or die ("blowed up<br>"); fclose($filehandler); ?> Gives me this: Warning: fopen(testFile.txt): failed to open stream: Permission denied in /usr/share/freemed-0.8.4/test.php on line 16 blowed up It's certainly not FreeMED's fault. My PHP scripts just don't have write permission for the directory they're in, but I don't know why. Quote Link to comment https://forums.phpfreaks.com/topic/70653-file-write-permissions/#findComment-355140 Share on other sites More sharing options...
Daniel0 Posted September 25, 2007 Share Posted September 25, 2007 Try running this from the shell: $ chmod 777 /usr/share/freemed-0.8.4 Quote Link to comment https://forums.phpfreaks.com/topic/70653-file-write-permissions/#findComment-355146 Share on other sites More sharing options...
jotate Posted September 25, 2007 Author Share Posted September 25, 2007 Try running this from the shell: $ chmod 777 /usr/share/freemed-0.8.4 Did it a while ago. Actually did: $ chmod -Rv 777 /usr/share/freemed-0.8.4 It's wide open, which is why I'm so stumped. Quote Link to comment https://forums.phpfreaks.com/topic/70653-file-write-permissions/#findComment-355152 Share on other sites More sharing options...
Daniel0 Posted September 25, 2007 Share Posted September 25, 2007 Hmm... which permissions does it say it has then? Did you get any permission denied error when running the chmod command? Quote Link to comment https://forums.phpfreaks.com/topic/70653-file-write-permissions/#findComment-355157 Share on other sites More sharing options...
jotate Posted September 25, 2007 Author Share Posted September 25, 2007 Hmm... which permissions does it say it has then? Did you get any permission denied error when running the chmod command? No errors that I can see from the chmod command. All the permissions in that directory are -rwxrwxrwx now. Quote Link to comment https://forums.phpfreaks.com/topic/70653-file-write-permissions/#findComment-355173 Share on other sites More sharing options...
Daniel0 Posted September 25, 2007 Share Posted September 25, 2007 <?php clearstatcache(); var_dump(is_writable('.')); var_dump(is_readable('.')); ?> Does that say that the directory isn't writable (by PHP)? Quote Link to comment https://forums.phpfreaks.com/topic/70653-file-write-permissions/#findComment-355250 Share on other sites More sharing options...
jotate Posted September 26, 2007 Author Share Posted September 26, 2007 bool(false) bool(true) So it's not writable. "Why?" is the question. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/70653-file-write-permissions/#findComment-355642 Share on other sites More sharing options...
Daniel0 Posted September 26, 2007 Share Posted September 26, 2007 Weird... maybe safe mode is on? Quote Link to comment https://forums.phpfreaks.com/topic/70653-file-write-permissions/#findComment-355644 Share on other sites More sharing options...
jotate Posted September 26, 2007 Author Share Posted September 26, 2007 Yah, I checked that. It's not. It occurred to me that maybe a firewall was blocking something, but then that doesn't make much since as PHP is all server side. So the server just sees apache as trying to create the file, which it should be able to as the owner of the directory and the permissions wide open. So it's not that. So...yeah. ??? Quote Link to comment https://forums.phpfreaks.com/topic/70653-file-write-permissions/#findComment-355652 Share on other sites More sharing options...
jotate Posted September 27, 2007 Author Share Posted September 27, 2007 Upgraded to php5. Still the same problems. I guess it's not a PHP problem. I'm completely at a loss, at the point of scraping the open source application and building from scratch. But this will continue to pose a problem for any future PHP work we try to do on that server. So frustrating... Quote Link to comment https://forums.phpfreaks.com/topic/70653-file-write-permissions/#findComment-356538 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.