views:

24

answers:

1

I created a setup.php to handle MySQL table generation, and as an obvious precaution I added a way to delete it after it was finished. As using unlink(__FILE__) is impossible to do, I added deletion code to main.php?action=deleteconfig to unlink the file.

setup.php has permissions 777, but it gives me a permission denied error when I unlink it.. My directory is drwxr-xr-x and my main.php is -rw-r--r--.

Would I need to set main.php to 777 as well before it can delete setup.php ? I am confused about file permissions here and why they do not work.

+1  A: 

The user running php needs to have write permissions for the directory in order to modify its contents (ie. delete/create). so you could chown the directory to the php user, or add the php user to the group and chmod the directory to so that the group ha w permissions.

prodigitalson
UH OH, I did `system('whoami');` and it said "nobody nobody", would I need to chown the file to nobody for this to work? Or is `nobody` no one .. a default?
John
`nobody` can have special connotations depending on what youre running. What OS is it?
prodigitalson
prodigitalson: Arch Linux
John
@john: sorry i haven 0 exp. with Arch. But i find it odd they run Apache as `nobody`. Typically on the flavors of linux i use its set up by default as something like `www` or `www-data`.
prodigitalson
I'm releasing the software to other people to use (online), so maybe I can warn them to ensure it's owned by the same user as httpd and it should be a problem, I'll try and dig up what I can about `nobody` in the time being. Thanks for the insight that you could provide!
John
Well generally speaking a hosting account is not going to run as `nobody` they are going to have a specific user and group that it runs as to facilitate other things.
prodigitalson
I'll accept, because it answers quite a few of my other questions I had in my head. Thank you!
John