Re: Question about directory permissions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sure.  The script runs with the permissions of whoever is running it.

In general, a PHP script that's a web page in linux will run by a user
called something like apache, apache2, www-user, or something similar.
 If you give that user permissions -- either directly or through their
group, often of the same name -- to write to the directory in
question, then the script will be able to write to it.

For instance:  on my Ubuntu 10.04 server, I want my script DW3 to be
able to write to /var/www/DW3/logs.  I leave ownership of everything
else as it was, and do the following:

$ cd /var/www/DW3
$ chgrp www-data ./logs
$ chmod 770 ./logs

Now members of the group www-data (at the moment only apache) can
write to the directory, as can the owner, but no one else can.  In
reality, I could probably have set that to 660, but I don't much care
about the slight added risk of using 770 in this case.  (If you're
confused by the numbers I used, check here:
http://www.yolinux.com/TUTORIALS/LinuxTutorialManagingGroups.html)


I hope that helps!

-Andy

On Mon, Mar 21, 2011 at 1:58 PM, Al <news@xxxxxxxxxxxxx> wrote:
> I understand dir perms pretty well; but, have a question I can't readily
> find the answer to.
>
> Under a Linux system, scripts can't write, copy, etc. to other dirs unless
> the perms are set for writable for the script e.g., nobody.
>
> But, is there a way a script can write or copy within its own dir?
>
> Thanks...
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux