Web Hosting Talk







View Full Version : Owner/permissions question on PHP written file


anakrino
03-24-2003, 07:26 PM
Hello,
I'm in the process of working with some PHP scripts that write/update some files on my web host. According to the instructions I need the files to be writable by the webserver but obviously I don't want them to be world writable. Whats the proper way to do this? Is there a special user that needs to own the files?

Thanks a million,
Anakrino

Spingen
03-24-2003, 07:32 PM
You could assign ownership of the directory or files that would be written to the webservers uid.

anakrino
03-24-2003, 07:34 PM
So should there be a user called "webserver"? A grep of /etc/passwd doesn't show one. And, if I change the owner on the file I'll lose all my rights to it from that point on, correct?

Thanks,
Anakrino

Spingen
03-24-2003, 08:15 PM
Originally posted by anakrino
So should there be a user called "webserver"? A grep of /etc/passwd doesn't show one. And, if I change the owner on the file I'll lose all my rights to it from that point on, correct?

Thanks,
Anakrino

You could just change the group ownership of the file/directory to apache or www (If you can't determine which user the webserver is running under ask you host) and modify the group permission to allow it to modify the file/directory. Then only you and the webserver can modify it.

nmluan
03-24-2003, 09:17 PM
If you change OWNER (chown) pemission as root, you'll always be able to change it back.

Most virtual hosts won't let you change ownership of your files no someone else.

You can view the user/group Apache that is running as by your phpinfo(); statement in a php script (search the page for User/Group - it's under "apache")

ML