![]() |
Query Server for Apache version only
Can someone please tell me why I get an undefined function error when running this code in the functions.php? I want to query the server for the Apache version without getting the long string you get using SERVER_SOFTWARE.
PHP Code:
|
apache_get_version() is only available in PHP version > 4.3.2, so this might be the cause.
Try this snippet: PHP Code:
|
Thank you, sir. That worked great! ;)
The server I am on is running PHP v4.3.3. I'm not sure why that code I posted doesn't work. It should have. :surprised: Is there also a way to get the version of UNIX or Linux (as my server has)? |
Is apache running as a module or as CGI? As apache_get_version() only works if its run as a module.
|
You got me on that one. I have no idea which way they have it set up. Apparently, it must be set up as CGI since the script gives me the unknown function error, right? :) Is one way really any better than the other?
Also, is there a way to pull the Linix version number out, too? |
Apache as a module is the better method to use, take a look at the Server API part of phpinfo() at the very top and it should say Apache if your running it as a module.
For the Linux version info, provided you can run shell_exec() you can get the OS info with: PHP Code:
Quote:
|
Is there such a thing as this for the Linux version?
#1 SMP Mon Aug 18 14:34:09 EDT 2003 That's what it returns. I only have this info displayed for Admins. It is not available to the other users. ;) The Server API just says Apache. |
If you mean the Linux Kernel version then uname -r is what you want.
I've just tired apache_get_version(); on my server and it seems to work correctly for me with the Server API as Apache (ie a module), however, I think what you get returned from that is the same as you'll get from getenv('SERVER_SOFTWARE'); as both return Apache for me as I've set it to not show any other details in httpd.conf. |
It must be running as CGI on my server then. That would explain why I get the error. The code KirbyDE posted above gave me just the version number of Apache and nothing else. That's all I needed as I already have the other info.
I tried the -r and this is what I got: 2.4.20-20.7smp Does that look right to you? What does the smp stand for? What is the exact code you used with this? apache_get_version(); |
Yes, that looks right ;) The SMP (symmetric multiprocessing) part means your kernel has been complied to support more than one CPU.
I just did: PHP Code:
|
This is what I get when I try to run it:
Fatal error: Call to undefined function: apache_get_version() in XXXXXXXXXX :( |
All times are GMT. The time now is 07:40 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|