Jump to content

Sorting out permissions between host server and local Apache install??


Recommended Posts

I am trying to duplicate a functionality on my hosted server locally, so that I can develop sites locally under my own copy of Apache, but I am running into a problem that is a showstopper and that I can't yet get around. 

 

Here is test php file.

 

<?php
if (file_put_contents("junk.txt", "Hi there.  I am inside of junk.txt!")) {
   echo "File was WRITTEN to disk!";
} else {
   echo "File was unable to be written!";
}
?>

 

When I run the above file under my local copy of Apache (running as user www-data) the above script fails to write the file junk.txt.

 

When I run it at my hosted server...no problem.  It writes the file just fine. 

 

Locally when I "touch junk.txt" from a command line the junk.txt file is created with a permission of -rw-r--r-- (I don't know what the corresponding number of that chmod is).

 

Same thing on the hosted server. 

 

If I create the file locally and change the permissions to -rw-rw-rw-, no problem. 

 

But I don't need to first create the file and change it's permissions on the hosted server to successfully run this script and needless to say having to create files first and open up the permissions somewhat locally every time my scripts want to create a file just won't cut it. 

 

The directory permissions of both document root directories is also the same and are both set at drwxr-x---

 

How can I get around this obstacle and make my local Apache able to write files like it can on the hosted server? 

 

Any help on this would be appreciated. 

 

Thanks.

 

Carlos

I just discovered one difference between my local install and the hosted Apache install. 

 

On the hosted server the ownership of the public_html directory is user:carlos and group:nobody.

 

Locally it is user:carlos and group:carlos

 

So obviously the group on the hosted Apache (i.e. nobody) has write permissions to the document root that the group locally (i.e. carlos) does not. 

 

Hmm...now I have figure out how to tell what permissions the group, carlos, how to change them, and whether I am even should. 

 

Carlos

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.