What are the best file permission settings for PHP scripts? Any suggestions on ways to figure out the minimum required permissions?
+5
A:
WalloWizard is correct that you should only use the minimum permissions necessary for the script to function.
However, let me be more specific, assuming that you're running on a Unix-based system such as Linux or BSD or Mac OSX. Your web server usually runs as an unprivileged user such as "nobody" and your scripts need to be readable by that user, so the best permissions are usually 644, meaning that you can read and write the script, and everyone else can only read it.
In the uncommon case that the script is owned by the same user running the web server, you can set the permissions to 600, so that you can read and write the script and no one else can even read it.
Eli Courtwright
2008-09-14 01:30:59