Reply to Re: PHP fails writing to text file?

Your name:

Reply:


Posted by Daniel Ennis on 09/30/67 12:00

Gilles Ganault wrote:
> On Tue, 15 Jan 2008 05:12:57 +0100, Gilles Ganault <nospam@nospam.com>
> wrote:
>> What am I doing wrong? Is it some kind of security feature in Apache
>> or the OS that's preventing the script from writing the text file?
>
> Found what it was:
>
> =======
> # ll
> drwxr-xrwx 2 root wheel 512 Jan 15 05:20 .
>
> # chmod 757 ./.
> =======
>
> Now, index.php can write into Apache's htdocs/ but I doubt this is the
> right solution. Does it mean that PHP scripts shouldn't write any file
> into htdocs/ ?
>
> Thanks.

Well to your problem yes it is the solution. Your running PHP as an
apache module, which makes the script run as www.

that htdocs folder is not owned by www nor in same group, so you have to
have 'Other' Permissions with Write access (the 3rd digit thats a 7 =
all access for Other).

Now, if your in a dedicated hosting environment, this is fine, but can
be annoying when writing files.

If you plan on hosting anyone elses site, or if you just want a little
more security/ease of file permissions look into suPHP.

suPHP is nice because it allows the php process to run as the same group
as the user running it, in other words does not require anything but
Owner permissions for Writing.

You could also chown the directory your writing too also to allow
access, or touch test.txt, chown www:www test.txt , and chmod 0755 test.txt

That way the file is already created, and index.php has permission to
write to it.


--
Daniel Ennis
faNetworks.net - Quality Web Hosting and Ventrilo Services
System Administrator / Web Developer
PHP Developer for 6 years
daniel@fanetworks.net

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация