Server Core(Windows Server 2008 R2) に、PowerShellのServerManagerやWebAdministration用コマンドレットを使用して、IISのインストールと設定、PHPをインストールします。
pkgmgr と AppCmd を使って IIS のインストールや設定する場合は、下記サイトが参考になるかと思います。
http://www.microsoft.com/japan/opensource/php/learning/article3.mspx
■PHPのインストール
1.クライアントなどで下記のサイトからWindows Binaries のzip packageをダウンロードします。
http://www.php.net/downloads.php
※今回はPHP 5.2.10 zip package をダウンロードしています。
2.ダウンロードしたファイルを解凍し、 Server Core の「c:\php5」にコピーします。
※今回は「c:\php5」にインストールします。
3.「php.ini-dist」 をコピーして 「php.ini」 を作成します。
4.「php.ini」を notepad などで開いて extension_dir の値を "c:\php5\ext" に変更します。
■IISのインストールと設定
1.PowerShell をインストールします。
ServerCore で PowerShell を使う
http://www.gine.jp/blog/taka/post/ServerCore-e381a6-PowerShell-e38292e4bdbfe794a8.aspx
2.ServerManager モジュールをインポートします。
サーバー マネージャー用 コマンドレットを使う
http://www.gine.jp/blog/taka/post/e382b5e383bce3838fe383bc-e3839ee3838de383bce382b7e383a3e383bce794a8-e382b3e3839ee383b3e38388e383ace38383e38388e38292e4bdbfe38186.aspx
3.IISをインストールします。今回はフルインストールを行っています。
Add-WindowsFeature Web-Server -i
4.実行ポリシーが規定だと「Restricted」になっており、スクリプトが実行できないので、スクリプトを実行できるように設定します。
Set-ExecutionPolicy RemoteSigned
5.IIS WebAdministration モジュールをインポートします。
import-module WebAdministration
6.fastCGIの設定を行います。
Add-WebConfiguration /system.webServer/fastCGI -value @{fullPath="c:\php5\php-cgi.exe"}
7.モジュールマップを追加します。
Add-WebConfiguration
/system.webServer/handlers
"IIS:\sites\Default Web Site"
-value @{path="*.php";verb="GET,HEAD,POST,DEBUG";name="php";
modules="FastCgiModule";scriptProcessor="c:\php5\php-cgi.exe"}
※実際のコマンドでは改行は不要です。
8.規定のドキュメントに「index.php」を追加しておきます。
Add-WebConfiguration
/system.webServer/defaultDocument/files
"IIS:\sites\Default Web Site"
-value @{value="index.php"}
※実際のコマンドでは改行は不要です。
■動作確認
PHPの動作確認のため、「C:\Inetpub\wwwroot」に、以下の内容でtest.phpを作成します。
<?php phpinfo()?>
尚、Server CoreにIEはインストールできませんが、Firefoxはインストールできますので、ローカルで確認も可能です。
