faqts : Computers : Programming : Languages : PHP : Not Quite PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 7 people (14%) answered Yes
Recently 1 of 7 people (14%) answered Yes

Entry

How do I change a php created a folder whose owner is 'www' to a different owner?

Mar 28th, 2008 17:53
ha mo, Ttt Koba, John Marc, Michael Felt, David Uhrig, http://us3.php.net/manual/en/function.chown.php


I am assuming you are talking about a web-site running an apache server
on a UNIX box.
PHP is not an identity, so PHP as such is not creating anything. If the
owner of the created object (both files and folders (or directories in
UNIX terms)) is www then the only way to change USER ownership is to get
an admin with su (or root) rights to change the user ownership using the
unix command
chown new_owner file|directory
If it is group ownership you want to change (e.g. from www to webdev)
and you are the owner of the file or folder (read directory) then just
use the command
chgrp new_group file|directory
If you are not the file|directory owner - see root again.
If you become the owner, and do change the group name, and the apache
server is still suppossed to read it as www:www then make sure the
"other" permsisions bits are set correctly (these are also called world
permission settings because everyone_else can read and/or modify your
file based on these perms.
Generally for folders (directories) use:
chmod o=rx directory
for files:
chmod o=r files
Generally you should not use numeric versions of the chmod command (e.g.
chmod 777 file) because it may set, or unset more than you want.
-----
JMV added:
PHP has a chown command.  www is usually the web server, which php is 
run from, so tecnically you should be able to change a file owned by 
www to something else.
-----
Kobattt
Remember that only super user (root) can change the owner of a 
file/directory.
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.yamot.com
http://www.mozmar.com
http://www.templatestemp.com