[Tfug] writing files from PHP

Paul Scott waterhorse at ultrasw.com
Wed Jun 18 10:53:21 MST 2008


keith smith wrote:
>
>
> That is a very good question.  One I have been wrestling with for a while.
>
> I have found several things to address this.  I'm hoping others on the
> list will replay to this post.
>
> The version of PHP is not relevant as far as I know.  Most of the
> world is now running PHP5 or is in the process of upgrading.
>
> I find changing the directory permissions to 777 and the file
> permissions to 666 allow for reading and writing a file using PHP.
>
> Having a directory set to 777 is not secure and I think most will
> advise not to do this.
>
And clearly not necessary since the at least one server that I am
successful with has directory permissions of 750 and file permissions of
644.
>
> The solution might be to set the ownership of the directory and
> possibly it's contents to the same user as Apache.  I seem to remember
> doing so on a project a year or so ago.
>
I don't think that's a choice on a commercial web host but that may be
close to the problem.  Judd mentioned having Apache (www-data) in the
same group.  I am also looking at the Apache conf files.
>
> The only problem with changing directory ownerships (chmod) in a
> shared hosting environment you probably do not have permission to do so.
>
Exactly and clearly not necessary.  I certainly don't want to give that
kind of permission on one of my machines.

Thanks,

Paul





More information about the tfug mailing list