mirror of
https://github.com/silverstripe/silverstripe-installer
synced 2024-10-22 17:05:33 +02:00
ENHANCEMENT #5080 SilverStripe can now be installed successfully on servers that do not have any rewrite capability
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/phpinstaller/branches/2.4@101343 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
07ddefe9f7
commit
682a141d7c
69
install.php
69
install.php
@ -341,9 +341,9 @@ class InstallRequirements {
|
|||||||
$this->isRunningWebServer(array("Webserver Configuration", "Server software", "Unknown web server", $webserver));
|
$this->isRunningWebServer(array("Webserver Configuration", "Server software", "Unknown web server", $webserver));
|
||||||
|
|
||||||
if($isApache) {
|
if($isApache) {
|
||||||
$this->requireApacheModule('mod_rewrite', array("Webserver Configuration", "mod_rewrite enabled", "You need mod_rewrite to run SilverStripe CMS, but it is not enabled."));
|
$this->requireApacheRewriteModule('mod_rewrite', array("Webserver Configuration", "mod_rewrite enabled", "You need mod_rewrite to use friendly URLs with SilverStripe, but it is not enabled."));
|
||||||
} elseif($isIIS) {
|
} elseif($isIIS) {
|
||||||
$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. Download it for IIS 7 from http://www.iis.net/expand/URLRewrite"));
|
$this->requireIISRewriteModule('IIS_UrlRewriteModule', array("Webserver Configuration", "IIS URL Rewrite Module enabled", "You need to enable the IIS URL Rewrite Module to use friendly URLs with SilverStripe, but it is not installed or enabled. Download it for IIS 7 from http://www.iis.net/expand/URLRewrite"));
|
||||||
} else {
|
} else {
|
||||||
$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->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."));
|
||||||
}
|
}
|
||||||
@ -585,15 +585,54 @@ class InstallRequirements {
|
|||||||
|
|
||||||
function requireApacheModule($moduleName, $testDetails) {
|
function requireApacheModule($moduleName, $testDetails) {
|
||||||
$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);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function testApacheRewriteExists($moduleName = 'mod_rewrite') {
|
||||||
|
if(in_array($moduleName, apache_get_modules())) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function testIISRewriteModuleExists($moduleName = 'IIS_UrlRewriteModule') {
|
||||||
|
if(isset($_SERVER[$moduleName]) && $_SERVER[$moduleName]) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function requireApacheRewriteModule($moduleName, $testDetails) {
|
||||||
|
$this->testing($testDetails);
|
||||||
|
if($this->testApacheRewriteExists()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
$this->warning($testDetails);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if the web server has any rewriting capability.
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function hasRewritingCapability() {
|
||||||
|
return ($this->testApacheRewriteExists() || $this->testIISRewriteModuleExists());
|
||||||
}
|
}
|
||||||
|
|
||||||
function requireIISRewriteModule($moduleName, $testDetails) {
|
function requireIISRewriteModule($moduleName, $testDetails) {
|
||||||
$this->testing($testDetails);
|
$this->testing($testDetails);
|
||||||
if(isset($_SERVER[$moduleName]) && $_SERVER[$moduleName]) {
|
if($this->testIISRewriteModuleExists()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$this->error($testDetails);
|
$this->warning($testDetails);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -904,7 +943,8 @@ PHP
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the appropriate web server configuration file
|
// Write the appropriate web server configuration file for rewriting support
|
||||||
|
if($this->hasRewritingCapability()) {
|
||||||
if($isApache) {
|
if($isApache) {
|
||||||
$this->statusMessage("Setting up '.htaccess' file...");
|
$this->statusMessage("Setting up '.htaccess' file...");
|
||||||
$this->createHtaccess();
|
$this->createHtaccess();
|
||||||
@ -912,6 +952,7 @@ PHP
|
|||||||
$this->statusMessage("Setting up 'web.config' file...");
|
$this->statusMessage("Setting up 'web.config' file...");
|
||||||
$this->createWebConfig();
|
$this->createWebConfig();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Load the sapphire runtime
|
// Load the sapphire runtime
|
||||||
$_SERVER['SCRIPT_FILENAME'] = dirname(realpath($_SERVER['SCRIPT_FILENAME'])) . '/sapphire/main.php';
|
$_SERVER['SCRIPT_FILENAME'] = dirname(realpath($_SERVER['SCRIPT_FILENAME'])) . '/sapphire/main.php';
|
||||||
@ -958,11 +999,21 @@ PHP
|
|||||||
$_SESSION['password'] = $config['admin']['password'];
|
$_SESSION['password'] = $config['admin']['password'];
|
||||||
|
|
||||||
if(!$this->errors) {
|
if(!$this->errors) {
|
||||||
if(isset($_SERVER['HTTP_HOST'])) {
|
if(isset($_SERVER['HTTP_HOST']) && $this->hasRewritingCapability()) {
|
||||||
$this->statusMessage("Checking that friendly URLs work...");
|
$this->statusMessage("Checking that friendly URLs work...");
|
||||||
$this->checkRewrite();
|
$this->checkRewrite();
|
||||||
} else {
|
} else {
|
||||||
echo "\n\nSilverStripe successfully installed\n";
|
echo <<<HTML
|
||||||
|
<li>SilverStripe successfully installed; I am now redirecting you to your SilverStripe site...</li>
|
||||||
|
<script>
|
||||||
|
setTimeout(function() {
|
||||||
|
window.location = "index.php/home/successfullyinstalled?flush=1";
|
||||||
|
}, 2000);
|
||||||
|
</script>
|
||||||
|
<noscript>
|
||||||
|
<li><a href="index.php/home/successfullyinstalled?flush=1">Click here to access your site.</li>
|
||||||
|
</noscript>
|
||||||
|
HTML;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1003,12 +1054,14 @@ PHP
|
|||||||
Deny from all
|
Deny from all
|
||||||
</Files>
|
</Files>
|
||||||
|
|
||||||
|
<IfModule mod_rewrite.c>
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
$baseClause
|
$baseClause
|
||||||
|
|
||||||
RewriteCond %{REQUEST_URI} ^(.*)$
|
RewriteCond %{REQUEST_URI} ^(.*)$
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
|
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
|
||||||
|
</IfModule>
|
||||||
TEXT;
|
TEXT;
|
||||||
|
|
||||||
if(file_exists('.htaccess')) {
|
if(file_exists('.htaccess')) {
|
||||||
|
Loading…
Reference in New Issue
Block a user