What are the best file permission settings for PHP scripts? Any suggestions on ways to figure out the minimum required permissions?
What are the best file permission settings for PHP scripts? Any suggestions on ways
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.