ohdang888 Posted March 7, 2011 Share Posted March 7, 2011 I have a simply script like this: $fh = fopen("test/test.js", 'w+') or die("can't open file"); fwrite($fh, $output); fclose($fh); It ONLY works if the "test" directory has a 777 permissions. Works like a charm then, but the moment it goes to even 775, I get this: Warning: fopen(test/test.js) [function.fopen]: failed to open stream: Permission denied in /var/www/vhosts/mydomain.com/httpdocs/f.php on line 42 Any thoughts? I don't want this folder to remain 777 Thanks Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted March 7, 2011 Author Share Posted March 7, 2011 bump Quote Link to comment Share on other sites More sharing options...
beegro Posted March 7, 2011 Share Posted March 7, 2011 It sounds like the web server isn't a member of the group that has rights to write to the file. Try chgrp -R apache test chmod -R 0775 test Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted March 7, 2011 Author Share Posted March 7, 2011 It sounds like the web server isn't a member of the group that has rights to write to the file. Try chgrp -R apache test chmod -R 0775 test Thanks! Unforunately, it says "apache" is not a group. i used "less /etc/group" to list all groups, and i have the list, but for security sake i feel like it wouldn't be smart to post that.. Anyways, i ran "ps aux | grep httpd" and "ps aux | grep apache" to see which users run PHP scripts, and i found root, and www-data, and "nobody" so i added both of those to a group (confirmed it too), and did chgrp -R mygroup /var/www/vhosts/domain/httpdocs/test chmod -R 0775 /var/www/vhosts/domain/httpdocs/test And it changed it (confirmed it). Unforunately, I went to the site in the browser, and its coming up with 403 forbidden. I've change it back to the group being "root" (what it was before the change), and now its STILL not working. Still getting a 403 error. GAH Any thoughts are GREATLY appreciated. Thanks Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted March 7, 2011 Author Share Posted March 7, 2011 Alright: went from a recent backup, and started over. The 403 is gone, but of course the script is still not working. GAHHHHH Quote Link to comment 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.