Is there a way in PHP to figure out the Linux distribution name of a remote server?
Extracting from $_SERVER['HTTP_USER_AGENT']
is just the OS name of the client's machine. It is not what I want. I tried php_uname()
echo 'Operating System: '.php_uname('s').'<br>'; // echo PHP_OS;
echo 'Release Name: '.php_uname('r').'<br>';
echo 'Version: '.php_uname('v').'<br>';
echo 'Machine Type: '.php_uname('m').'<br>';
But the mode s
returns only the kernel type - Linux.
Operating System: Linux
Release Name: 2.6.32-431.29.2.el6.x86_64
Version: #1 SMP Tue Sep 9 21:36:05 UTC 2014
Machine Type: x86_64
I want to know it is Fedora, CentOS or Ubuntu, etc. Is it possible? I have also tried posix_uname(), but got an error.
Fatal error: Call to undefined function posix_uname()
Try a PHP
system($call)
call http://php.net/manual/en/function.system.php There you can do whatever you want to find out the desired infomation, on an ubuntu system, you might for example want to usesystem('cat /etc/issue');
You might want to use an approach, where you call a bash script from PHP, for example https://unix.stackexchange.com/questions/6345/how-can-i-get-distribution-name-and-version-number-in-a-simple-shell-script