When I try to run apache_get_version()
function on my website, I get an error:
Fatal error: Uncaught Error: Call to undefined function apache_get_version() in /srv/www/mywebsite.com/index.php:44 Stack trace: #0 {main} thrown in /srv/www/mywebsite.com/index.php on line 44
However this works in my localhost. I tried
function apache_version()
{
$ver = explode(" ",$_SERVER["SERVER_SOFTWARE"],3);
return ($ver[0] . " " . $ver[1]);
}
echo apache_version();
This should echo the server version on apache though it doesn't echo the version
From the introduction to Apache functions:
These functions are only available when running PHP as an Apache module.
If you run PHP as CGI/FastCGI or any other SAPI, there's just no reliable way to determine Apache version because the interaction of PHP with Apache is minimum. If the server does not report it (thus you can read it somewhere at $_SERVER
) you're out of luck.
You can also determine how PHP runs with phpinfo()
.
Maybe you could try
<?php
echo shell_exec('httpd -version');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With