title: npm does not run when called through nginx/php-fpm exec
body: <p>I have a strange issue in my autodeploy script. </p>
  
  <p>Basically that's the php script, that, when triggered through http, runs the other shell script with several commands like <code>npm install</code> and <code>npm run build</code>. This all works except the case when php script called from http nginx/php-fpm - this case npm command does not run. </p>
  
  <p>I created the simple example repo to demonstrate the issue: <a href="https://github.com/Kasheftin/npm-bug" rel="nofollow noreferrer">https://github.com/Kasheftin/npm-bug</a></p>
  
  <p>We have test.php that just runs test.sh shell command:</p>
  
  <pre><code>&lt;?php
    exec("/home/www/tests/npm-bug/test.sh &gt; /home/www/tests/npm-bug/test.log");
  </code></pre>
  
  <p>We have test.sh that just runs <code>npm run test</code> command:</p>
  
  <pre><code>#!/bin/bash
  cd /home/www/tests/npm-bug
  npm run test
  </code></pre>
  
  <p>Finally we have package.json with the following command:</p>
  
  <pre><code>"scripts": {
    "test": "echo \"Hello World!\""
  }
  </code></pre>
  
  <p>The result of <code>npm run test</code> looks like:</p>
  
  <pre><code>&gt; npm-bug@1.0.0 test /home/www/tests/npm-bug
  &gt; echo "Hello World!"
  
  Hello World!
  </code></pre>
  
  <p>Notice the last row - that's the result of the echo command in package.json. The same result appears in the case of <code>./test.sh</code> command. And the same we get in <code>test.log</code> after running <code>php test.php</code> command. </p>
  
  <p>But when I trigger test.php from http, I get only </p>
  
  <pre><code>&gt; npm-bug@1.0.0 test /home/www/tests/npm-bug
  &gt; echo "Hello World!"
  </code></pre>
  
  <p>Notice, that the last string is absent, npm command did not run.</p>
  
  <p>Also I have this location rule in my nginx:</p>
  
  <pre><code>location = /npm-test {
    root /home/www/tests/npm-bug;
    rewrite ^(.*)$ /test.php break;
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
  }
  </code></pre>
  
  <p>This all seems to be very standart, nginx and php7.0-fpm are right out of the box, the php config is just the same for cli and for fpm. Checked on two servers with different environment.</p>