carlos1234 Posted November 3, 2009 Share Posted November 3, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/180146-sorting-out-permissions-between-host-server-and-local-apache-install/ Share on other sites More sharing options...
carlos1234 Posted November 3, 2009 Author Share Posted November 3, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/180146-sorting-out-permissions-between-host-server-and-local-apache-install/#findComment-950342 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.