Re: Question about directory permissions
| From: | Andy McKenzie | Date: | Mon, 21 Mar 2011 18:27:02 +0000 |
| Subject: | Re: Question about directory permissions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-311980@lists.php.net to get a copy of this message | ||
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@ridersite.org> 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
>
>