How do I get the Apache version?
Actually, I want to use the setenv()
function in a PHP file, but I am not able to use that. It throws an error, undefined call to a function setenv()
. It might be because of my Apache version.
Join Stack Overflow to learn, share knowledge, and build your career.
How do I get the Apache version?
Actually, I want to use the setenv()
function in a PHP file, but I am not able to use that. It throws an error, undefined call to a function setenv()
. It might be because of my Apache version.
Here is a nice script for it: http://snipplr.com/view/10881/get-apache-version/
The Apache version is contained in the predefined variable:
$_SERVER['SERVER_SOFTWARE']
You could also use phpinfo() to get much information about the server, including all $_SERVER variables, activated modules and disabled functions.
ServerTokens
directive (which can only be set in the main server config, governing the whole server). If this is explicitly set to ServerTokens Prod
then you will only get the string "Apache" returned to PHP.
– MrWhite
Nov 4 '16 at 14:10
$SERVER
is a nice array , but what's wrong with the simple built-in apache_get_version() ? :- )
– Obmerk Kronen
Jan 4 '17 at 4:47
You should be able to use the simple built-in php function apache_get_version()
;
from php manual :
<?php
$version = apache_get_version();
echo "$version\n";
?>
apache_get_version()
- depends on settings in the httpd.conf file (ServerTokens). So, in relation to the settings, it can simply return Apache
, without any version/details...
– Andron
Mar 6 '19 at 8:51