3

Is there an alternative way to get my Apache version without using the below code?

<?php echo $_SERVER['SERVER_SOFTWARE']; ?>

Returns "Apache".

<?php echo apache_get_version(); ?>

Returns "Fatal error: Call to undefined function apache_get_version()".

Note: I am using a Linux server with PHP v5.3.1, and anything returned with a linux-only command via the shell using exec() or shell_exec() would be acceptable. I just want to get it detecting the version of Apache for Linux at least.

4
  • exec with httpd -v or try curl -I localhost and parse that Commented Jul 2, 2013 at 17:51
  • Tried both but they don't return anything. Commented Jul 2, 2013 at 17:53
  • Erk, given the SERVER_SOFTWARE environment variable, my previous comment was indeed a dumb question. Output of php_sapi_name() could be interesting to see, though. Commented Jul 2, 2013 at 18:10
  • The output from php_sapi_name() is "cgi-fcgi". Commented Jul 2, 2013 at 18:35

2 Answers 2

1

Have you tried apache_get_version()?

Sign up to request clarification or add additional context in comments.

Comments

0

you say using exec is fine ?

exec("apache2 -v") will give the output similar to

Server version: Apache/2.2.16 (Debian)
Server built:   Nov 30 2012 08:33:45

using your first command would be best and just makiing apache expose itself a little more

http://httpd.apache.org/docs/2.2/mod/core.html#ServerTokens

Change the .htaccess or the httpd.conf file to the token you want

2 Comments

It's not returning anything either. I also cannot configure ServerTokens from .htaccess and I do not have access to the httpd.conf file.
Note: ServerTokens may only be set in the server config (httpd.conf), not in .htaccess.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.