|
Writing to Files With PHP |
|
|
Written by Kim Howard
|
|
Tuesday, 13 September 2005 |
|
How Do I Let PHP Scripts Write To Files Without Making Them World Writable? The webserver runs as user www, as will your php scripts. You can give just user www permission to write to a file or direcotory using extended acls (access control lists). This will give www write perms to a file: setfacl -r -m user:www:rwx filename
To see what extended perms are on the file, you can use the command: getfacl filename You'll see a list like this # file: dispatch.file # owner: kim # group: them user::rwx user:www:rwx #effective:rw- group::r-- #effective:r-- mask:rw- other:--- The webserver can then write to the file. (But so can everyone else running a php script, because their scripts will also run as user www!!) But regular users should not be able to write to it. You can use the same commands on a directory. Check the setfacl and getfacl man pages for more info. |
|
Last Updated ( Tuesday, 13 September 2005 )
|