Jump to content

file permissions are driving me CRAZY


ohdang888

Recommended Posts

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

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.