title: How to set php_flag per-directory using php-fpm?
body: <h1>My problem</h1>
  
  <p>I want to turn off the <em>php engine</em> in a specific folder, where users can upload files, but I can't seem to figure it out.</p>
  
  <p><strong>PHP Version:</strong> 5.5.26</p>
  
  <p><strong>PHP mode:</strong> php-fpm (FastCGI Process Manager)</p>
  
  <p><strong>Apache version:</strong> 2.2.29</p>
  
  <p>(<strong>Server:</strong> Synology DS212j - DSM 5.2)</p>
  
  <p><em>Anything else you need to know?</em>
  <br><br><br></p>
  
  <h1>What I've tried so far:</h1>
  
  <h3>Disable from .htaccess-file</h3>
  
  <p>This is not supported by php-fpm (and some other modes), it gives a 500 error, logging:</p>
  
  <pre><code>Invalid command 'php_value', perhaps mis-spelled or defined by a module not included in the server configuration.
  </code></pre>
  
  <h3>Per-directory php.ini</h3>
  
  <p>I've tried per-directory php.ini-files (putting an additional php.ini-file in the avatars directory), but didn't get that working. PHP never loaded the file. Not sure what I did wrong, I tried naming it both <em>php.ini</em> and <em>.user.ini</em>, neither worked.</p>
  
  <h3>Main php.ini section</h3>
  
  <p>I also tried using a section in the main <em>php.ini</em> file,</p>
  
  <pre><code>[path=/path/to/secure/dir]
  engine = off
  max_execution_time = 300
  </code></pre>
  
  <p>When I did that and ran <code>phpinfo()</code> in a file in the secure dir the <code>max_execution_time</code> was set to 300 (so the file has been reloaded), but the engine was still running (I assume, since the <code>phpinfo()</code> was shown). </p>
  
  <h3>php-fpm pools</h3>
  
  <p>I've also read about php-fpm pools, but it seems to me that you can only specify pools by domain/vhost, <strong><em>am I wrong?</em></strong></p>
  
  <h3>Edit vhost</h3>
  
  <p>I tried disabling it from the vhosts-file (is that what it's called?), in a <code>&lt;Directory /path/to/secure/dir&gt;</code> section as suggested <a href="https://stackoverflow.com/a/18948152/739534">here</a>, but that wasn't supported either.
  <br><br><br></p>
  
  <h2>Extra info</h2>
  
  <p>I'm building an application based on <a href="https://github.com/panique/huge" rel="nofollow noreferrer">Paniques's HUGE</a>. In <a href="https://github.com/panique/huge/blob/master/public/avatars/.htaccess" rel="nofollow noreferrer">the .htaccess-file</a> in the upload directory the php engine is turned off (for security reasons), using <code>php_flag engine off</code>.</p>