开发者

Get current Apache version string for display

开发者 https://www.devze.com 2022-12-25 16:29 出处:网络
I\'m writing an Apache module and want to get a string with the Apache name version and other details. Much like what gets added to outgoing headers, e.g.:

I'm writing an Apache module and want to get a string with the Apache name version and other details. Much like what gets added to outgoing headers, e.g.:

Server: Apache/2.2.13 (开发者_C百科Win32)

I've tried code like this:

apr_table_get(request_rec->headers_out,"Server")

But that doesn't seem to work. Is there an API call I haven't found or am I doomed to get version resource data from httpd.exe?


try this command

apache2 -v

should print out something like this

Server version: Apache/2.2.11 (Ubuntu)
Server built:   Mar  9 2010 21:05:51

most unix commands have a -v option

it looks like you are trying to get it from php, the exec command in php will let you run the command on the server


Found it: ap_get_server_version, my HTTPD2 API wrapper was missing this declaration


I'm not sure about Apache modules, but for CGI scripts, the name of the current web server is stored in the SERVER_SOFTWARE environment variable. In Perl, for example, you would use $ENV{SERVER_SOFTWARE} to read it. In C you would use getenv ("SERVER_SOFTWARE").

In order to find out the server software, why not just grep through the Apache source codes to find where this is defined.

Doing this with Apache 1.3.41, I find that it is defined in a file called util_script.c on line 240 as follows:

ap_table_addn(e, "SERVER_SOFTWARE", ap_get_server_version());

It looks like there is a function called ap_get_server_version which returns the value as a string.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号