'How to get nginx web server version information in PHP
Consider the following code:
<?php
$command=isset($_GET["c"])?$_GET["c"]:"whoami";
echo "<pre>echo `$command`:\n"; echo `$command`;
echo "\nprint_r(exec(\"$command\")):\n"; print_r(exec($command));
echo "\n\nexec(\"$command\",\$c); print_r(\$c):\n"; exec($command,$c); print_r($c);
?>
This script is loaded in a browser to test the capture of shell output for various commands into PHP. Working examples:
?c=whoami - all three methods return the web user.
?c=uname a - all return linux information.
The problem is that with ?c=nginx -v nothing is output for any of the methods. However, all of the methods return the NginX version information when run via the PHP interactive shell. So, how do you get nginx information into a variable in the PHP script?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
