title: Execute Shell Script from PHP (Nginx, php-fpm, CentOS 7)
body: <p>I create php file which will execute shell script.</p>
  
  <p>First is a html file, user will input their Domain and IP Address:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Add new customer &lt;/title&gt;
  &lt;/head&gt;
  &lt;link href="stylesheets/common.css" type="text/css" rel="stylesheet"&gt;
  
  &lt;body&gt;
  
  &lt;h1&gt;Add new customer for monitoring&lt;/h1&gt;
  
  &lt;form method="post" action="web-add_new_customer.php"&gt;
  
  Domain: &lt;br /&gt;
  &lt;input type="text" name="DOMAIN" size="35" /&gt;
  &lt;br /&gt;
  
  IP Address: &lt;br /&gt;
  &lt;input type="text" name="IPADDRESS" size="35" /&gt;
  &lt;br /&gt; &lt;br /&gt;
  
  &lt;input type="submit" value="Submit new customer" /&gt;
  &lt;br /&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>And then, result from html file will display in some.php file to display what have been entered, and run shell script:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  $DOMAIN = $_POST['DOMAIN'];
  $IPADDRESS = $_POST['IPADDRESS'];
  
  
  if(empty($DOMAIN ) || empty($IPADDRESS )) {
  echo "&lt;h2&gt;You must fill in all fields&lt;/h2&gt;\n" ;
  die ("Click Back to start again.");
  }
  echo "&lt;h2&gt;You Entered the following information:&lt;/h2&gt;";
  echo "&lt;b&gt;DOMAIN:&lt;/b&gt;&lt;br&gt;&lt;br&gt;";
  echo $DOMAIN;
  echo "&lt;br&gt;&lt;br&gt;&lt;b&gt;IP Address:&lt;/b&gt;&lt;br&gt;&lt;br&gt;";
  echo $IPADDRESS;
  ?&gt;
  
  &lt;?php
  exec ( "/root/createfile.sh $DOMAIN $IPADDRESS" );
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I set createfile.sh owned by nginx. My server running nginx &amp; php-fpm, under CentOS 7.</p>
  
  <p>The php failed to execute shell script, any sugestions? Thank you.</p>