How do I execute SHELL directly in php

  • 2020-06-23 00:05:53
  • OfStack

$message=shell_exec("sudo /usr/local/webserver/nginx/sbin/nginx -t 2 > & 1");
echo "Operation result :".$message." < br/ > ";

The above statement can execute the SHELL statement directly in PHP

If there is a return value then two of them > & 1 is required and he will redirect the output strerr to strout output!

Otherwise the result will be empty!


Related articles: