[en] Installing SilverStripe on IIS server

UPDATE 2009-02-17: As Sigurd from Silver­Stripe team sta­tes in a com­ment, You shouldn’t need to fol­low my „howto” — at least if You’re using IIS 7. Since I wrote this „howto”, Silver­Stripe website has been impro­ved to inc­lude instal­la­tion instruc­tions on IIS so ple­ase give it a try before pro­ce­eding with my old instructions.

1. Install ISAPI/Rewrite. I have no idea how to do it since it was alre­ady instal­led at my provider’s server, but there pro­ba­bly is a limi­ted free ver­sion that is eno­ugh.
2. Down­load Silver­Stripe archive and extract it to Your server.
3. Go to Your server’s URL and fill in instal­ler deta­ils as usual.
4. After rew­ri­te­test fails, cre­ate httpd.ini file in Silver­Stripe root direc­tory and make its con­tents like that (what it basi­cally does with ISAPI/Rewrite is to mimic Apache’s mod_rewrite):

[ISAPI_Rewrite] RewriteEngine On

RewriteCond URL (?!.*gif|.*jpg|.*png|.*swf|.*xml|.*css|.*flv|.*js|.*php).*
RewriteCond URL (?!.*\?).*
RewriteRule (.*) /sapphire/main.php\?url=$1 [I,L]

RewriteCond URL (?!.*gif|.*jpg|.*png|.*swf|.*xml|.*css|.*flv|.*js|.*php).*
RewriteCond URL .*\?.*
RewriteRule (.*)\?(.*) /sapphire/main.php\?url=$1&$2 [I,L]

5. Click „click here to pro­ceed any­way” link and You sho­uld be redi­rec­ted to an ugly looking „suc­cess­fully instal­led” page.
6. Now edit /sapphire/core/control/Director.php file and change

$s = (isset($_SERVER[’SSL’]) || isset($_SERVER[’HTTPS’])) ? ‘s’ : ”;

line to

$s = (isset($_SERVER[’SSL’]) || (isset($_SERVER[’HTTPS’]) && $_SERVER[’HTTPS’] == ‘on’)) ? ‘s’ : ”;

7. Refresh the „suc­cess­fully instal­led” page and if it looks pretty now, You know You cor­rec­tly did step 6.
8. Click „Click here to delete the install files.” link so You don’t have a secu­rity hole.
9. Now edit /sapphire/main.php file and at the very begin­ning add these lines:

if (!isset($_SERVER[’REQUEST_URI’])) {
$_SERVER[’REQUEST_URI’] = $_SERVER[’SCRIPT_NAME’];
}

10. Fol­lo­wing are hacks I needed to add so i18n works on IIS. If You don’t use i18n, You’ll pro­ba­bly be fine without these hacks. This method is in sapphire/core/i18n.php file:

pro­tec­ted sta­tic func­tion get_owner_module($name) {
if (substr($name,-3) == ‘.ss’) {
glo­bal $_TEMPLATE_MANIFEST;
$path = current($_TEMPLATE_MANIFEST[substr($name,0,-3)]);
// hacks for IIS start –>
$path = str_replace(‘\sapphire/..’, ”, $path);
$path = str_replace(‘C:’, ”, $path);
$path = str_replace(‘\’, ‘/’, $path);
$bf = Director::baseFolder();
$bf = str_replace(‘C:’, ”, $bf);
$bf = str_replace(‘\’, ‘/’, $bf);
// <– end hacks
ereg($bf . ‘/([^/]+)/’,$path,$module);
} else {
glo­bal $_CLASS_MANIFEST;
$path = $_CLASS_MANIFEST[$name];
// hacks for IIS start –>
$path = str_replace(‘\sapphire/..’, ”, $path);
$path = str_replace(‘C:’, ”, $path);
$path = str_replace(‘\’, ‘/’, $path);
$bf = Director::baseFolder();
$bf = str_replace(‘C:’, ”, $bf);
$bf = str_replace(‘\’, ‘/’, $bf);
// <– end hacks
ereg($bf . ‘/([^/]+)/’,$path,$module);
}
return $module[1];
}

11. Enjoy :)
12. If You can’t enjoy for some reason, try chec­king out this thread at Silver­Stripe forum where most of the above info is found.

2 myśli nt. „[en] Installing SilverStripe on IIS server

  1. Hi:
    I use this manual and it wotks fine, but i change httpd.ini to:

    Rew­ri­te­En­gine On
    Rew­ri­te­Cond %{REQUEST_URI} !(.gif)|(.jpg)|(.png)|(.css)|(.js)|(.php)$
    Rew­ri­te­Cond URL (?!.?).
    Rew­ri­te­Rule (.*) /sapphire/main.php?url=$1 [I,L]

    because, with the your con­fi­gu­ra­tion SS can´t read the css files and image paths.

    My pro­blem is that i can´t access to admi­ni­stra­tion, it says:

    FATAL ERROR: None of these tem­pla­tes can be found: Security_dologin.ss, Security.ss
    At line 68 in C:InetpubwwwrootsapphirecoreSSViewer.php

    Any­body has the same problem?

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *

Możesz użyć następujących tagów oraz atrybutów HTML-a: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>