Alternatives to apache_get_modules() to get list of loaded apache modules
apache_get_modules() is only available when the PHP is installed as a module and not as a CGI. This is the reason why you cannot use this function and suffering from the error . The other reason would be caused by the disable_functions directive in your php.ini . you can use the following written php code to check whether rewrite module is enabled or not in your case while using CGI server API
<?php
if (is_mod_rewrite_enabled()) {
print "The apache module mod_rewrite is enabled.<br/>\n";
} else {
print "The apache module mod_rewrite is NOT enabled.<br/>\n";
}
/**
* Verifies if the mod_rewrite module is enabled
*
* @return boolean True if the module is enabled.
*/
function is_mod_rewrite_enabled() {
if ($_SERVER['HTTP_MOD_REWRITE'] == 'On') {
return TRUE;
} else {
return FALSE;
}
}
?>
To Check whether you are running Php Under CGI or Apache you can use procedure below
Create a check_phpinfo.php file and Write PHP Code Written Below -
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
Then Save the file and Navigate to Url like - www.example.com/check_phpinfo.php and It will show you php file in server
In Four line you can see "Server API CGI/FastCGI" That Denotes you are using PHP under CGI / Fast CGI
- phpinfo() will tell you how PHP is installed, especially the Server API row.
- You could parse the config files for Apache to find out which modules are configured.
- You could run something like
apache2 -t -D DUMP_MODULES
to obtain a list of modules.