ENHANCEMENT #4576 Detection of IIS and the IIS URL Rewrite Module during SS install

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/phpinstaller/branches/2.4@93110 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
sharvey 2009-11-23 20:11:29 +00:00 committed by Sam Minnee
parent 0fbaae8ba6
commit adfb282212

View File

@ -230,15 +230,22 @@ class InstallRequirements {
// Check for web server, unless we're calling the installer from the command-line // Check for web server, unless we're calling the installer from the command-line
if(!isset($_SERVER['argv']) || !$_SERVER['argv']) { if(!isset($_SERVER['argv']) || !$_SERVER['argv']) {
$webserver = strip_tags(trim($_SERVER['SERVER_SIGNATURE'])); $webserver = strip_tags(trim($_SERVER['SERVER_SIGNATURE']));
if($webserver == '') { if(!$webserver) {
$webserver = "I can't tell what webserver you are running"; if(isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'IIS') !== false) {
$pieces = explode('-', $_SERVER['SERVER_SOFTWARE']);
if(isset($pieces[1])) $webserver = $pieces[1];
} else {
$webserver = "I can't tell what webserver you are running";
}
} }
$this->isRunningApache(array("Webserver Configuration", "Server software", "$webserver. Without Apache I can't tell if mod_rewrite is enabled.", $webserver)); $this->isRunningWebServer(array("Webserver Configuration", "Server software", "$webserver. Without Apache I can't tell if mod_rewrite is enabled.", $webserver));
if(function_exists('apache_get_modules')) { if(function_exists('apache_get_modules')) {
$this->requireApacheModule('mod_rewrite', array("Webserver Configuration", "mod_rewrite enabled", "You need mod_rewrite to run SilverStripe CMS, but it is not enabled.")); $this->requireApacheModule('mod_rewrite', array("Webserver Configuration", "mod_rewrite enabled", "You need mod_rewrite to run SilverStripe CMS, but it is not enabled."));
} elseif(strpos($webserver, 'IIS') !== false) {
$this->requireIISRewriteModule('IIS_UrlRewriteModule', array("Webserver Configuration", "IIS URL Rewrite Module enabled", "You need to enable the IIS URL Rewrite Module, but it is not installed or enabled."));
} else { } else {
$this->warning(array("Webserver Configuration", "mod_rewrite enabled", "I can't tell whether mod_rewrite is running. You may need to configure a rewriting rule yourself.")); $this->warning(array("Webserver Configuration", "URL rewrite enabled", "I can't tell whether any rewriting module is running. You may need to configure a rewriting rule yourself."));
} }
$this->requireServerVariables(array('SCRIPT_NAME','HTTP_HOST','SCRIPT_FILENAME'), array("Webserver config", "Recognised webserver", "You seem to be using an unsupported webserver. The server variables SCRIPT_NAME, HTTP_HOST, SCRIPT_FILENAME need to be set.")); $this->requireServerVariables(array('SCRIPT_NAME','HTTP_HOST','SCRIPT_FILENAME'), array("Webserver config", "Recognised webserver", "You seem to be using an unsupported webserver. The server variables SCRIPT_NAME, HTTP_HOST, SCRIPT_FILENAME need to be set."));
@ -521,7 +528,17 @@ class InstallRequirements {
$this->testing($testDetails); $this->testing($testDetails);
if(!in_array($moduleName, apache_get_modules())) $this->error($testDetails); if(!in_array($moduleName, apache_get_modules())) $this->error($testDetails);
} }
function requireIISRewriteModule($moduleName, $testDetails) {
$this->testing($testDetails);
if(isset($_SERVER[$moduleName]) && $_SERVER[$moduleName] == 1) {
return true;
} else {
$this->error($testDetails);
return false;
}
}
function requireMysqlConnection($server, $username, $password, $testDetails) { function requireMysqlConnection($server, $username, $password, $testDetails) {
$this->testing($testDetails); $this->testing($testDetails);
$conn = @mysql_connect($server, $username, $password); $conn = @mysql_connect($server, $username, $password);
@ -617,13 +634,16 @@ class InstallRequirements {
} }
} }
function isRunningApache($testDetails) { function isRunningWebServer($testDetails) {
$this->testing($testDetails); $this->testing($testDetails);
if(function_exists('apache_get_modules') || stristr($_SERVER['SERVER_SIGNATURE'], 'Apache')) if(function_exists('apache_get_modules') || stristr($_SERVER['SERVER_SIGNATURE'], 'Apache')) {
return true; return true;
} elseif(strpos($_SERVER['SERVER_SOFTWARE'], 'IIS') !== false) {
$this->warning($testDetails); return true;
return false; } else {
$this->warning($testDetails);
return false;
}
} }