Jay Gilford
Jay Gilford

Reputation: 15151

Is it possible to find out if an Apache module is loaded in PHP

I'm looking at finding a way of checking if an apache module is loaded within a PHP script. The module in question is mod_xsendfile so that I can determine if I can use the X-SENDFILE header to output a secure file to the browser if available, or if I need to use readfile(). Any help is appreciated

Upvotes: 2

Views: 2713

Answers (2)

hakre
hakre

Reputation: 198217

Even if you find out that mod_xsendfile is loaded from within PHP, you need to keep in mind that this says nothing about it's configuration. You can not just automagically use it, because if available, it requires specific configuration to work with your PHP script.

Apart from that, there is apache_get_modules if you use PHP as an apache module itself.

Upvotes: 3

Gordon
Gordon

Reputation: 317217

You can use

Example from Manual:

print_r(apache_get_modules());

Example output:

Array
(
    [0] => core
    [1] => http_core
    [2] => mod_so
    [3] => sapi_apache2
    [4] => mod_mime
    [5] => mod_rewrite
)

Upvotes: 2

Related Questions