Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In my nginx conf.d file I have the following:

  location ~ \.php$ {
    try_files $uri = 404;
    fastcgi_pass unix:/tmp/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }

  location ^~ /dev/ {
    fastcgi_param PHP_VALUE display_errors=On;
  }

My goal was to have it so *.php was parsed by PHP in any directory, including the /dev/ directory and that, within the /dev/ directory, display_errors would be enabled. But it seems that the locations aren't being ANDed together but rather ORd. So if it matches *.php it parses it as a PHP file unless it's in the /dev/ directory.

Do I have to be redundant and have the PHP config code duplicated twice or is there a way I can avoid that redundancy?

Thanks!

share|improve this question

1 Answer 1

Yes, you have to be redundant. Except in very limited circumstances, location blocks are only parsed once, and the closest match wins.

Though you can reduce the pain of this by removing the common configuration parameters to a separate file and then using include to include it in both places.

share|improve this answer

Your Answer

 
discard

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.