Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Mistakes in the php {} part of vhost configuration files make php files to be "readable" with its source code like text files

Is there a global setting, e.g. in the default config to forbid accessing php files without fastcgi?

share|improve this question
up vote 0 down vote accepted

You could just use:

 location ~ \.php$ {
    deny all;

in case you want to make php files to be not accessible server wide or:

 location ~ /path/to/dir/(.+)\.php$ {
    deny all;

For a specific location.

share|improve this answer
This overwrites the other location php section (or is ignored). – ledy Jun 21 '12 at 7:06
This is the normal thing to do if you want to ignore php files. In order to know more, the full config needs to be present so to check all the aspects. – Logic Wreck Jun 21 '12 at 10:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.