Skip to content

Instantly share code, notes, and snippets.

@onubadev
Created February 15, 2016 10:26
Show Gist options
  • Save onubadev/1629f944f1f055504f85 to your computer and use it in GitHub Desktop.
Save onubadev/1629f944f1f055504f85 to your computer and use it in GitHub Desktop.
Check Apache modules availability in PHP
<?php
//Set the modules to check here
$modulesList = array(
'mod_rewrite',
'mod_mime',
'mod_expires',
'mod_deflate',
'mod_headers'
);
//Detection
$result = null;
if(function_exists('apache_get_modules') ){
foreach ($modulesList as $module) {
$result .= "$module: " . (in_array($module, apache_get_modules()) ? 'Available' : 'Not Available') . '<br>';
}
} else {
foreach ($modulesList as $module) {
$result.= "$module: " . (strpos(shell_exec('/usr/local/apache/bin/apachectl -l'), $module) !== false ? 'Available' : 'Not Available') . '<br>';
}
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Check apache modules</title></head>
<body>
<?php echo $result ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment