4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GoogleCloudPlatform Windows インスタンススタートアップスクリプトでIIS有効化

Last updated at Posted at 2015-10-09

Google Cloud Platform で Windows インスタンスが立ち上げられるようになりましたが、Googleが用意してくれているマシンイメージは初期状態でIISが有効になっていません。
幸いGoogle Compute Engine でもAWS同様インスタンス立ち上げ時スタートアップスクリプト指定ができますので、IIS初期化のコマンドを立ち上げ時スクリプトに指定しましょう。

Google Cloud PlatformでWindowsインスタンスの立ち上げはこちら。
http://qiita.com/karo-jp/items/67c8488385d83e26f705

デベロッパーコンソールからのスクリプト指定

Google Compute Cloud のデベロッパーコンソールのVMインスタンス新規作成画面から、次の赤丸部分をクリックしてメタ情報の入力画面を開きます。

console1.png

開いた画面で、

console2.png

「自動化」メタデータの「キー」に sysprep-specialize-script-ps1 「値」に

Install-WindowsFeature Web-Server -IncludeAllSubFeature

を入力してインスタンスの作成を行えば、インスタンス作成後初回にIISの機能有効化のPowerShellスクリプトが走ります。

初期化スクリプトメタデータの詳細ドキュメントはこちら。
https://cloud.google.com/compute/docs/startupscript#provide_a_startup_script_for_windows_instances

Webサイトトップページの初期化

LAMP環境でいうところのこんなの。

# ! /bin/bash
apt-get install -y apache2
cat <<EOF > /var/www/index.html
<html><body><h1>Hello World</h1>
<p>This page was created from a simple startup script!</p>
</body></html>
EOF

PowerShellではこんな感じで指定すればできます。

Install-WindowsFeature Web-Server -IncludeAllSubFeature
Set-Content -value "<html><body><h1>hello world</h1><p>This page was created from a simple startup script!</p></body></html>" -path C:\inetpub\wwwroot\index.html

RDPで入ってUIでIIS有効にしてイメージ作ってそこから起動すればいいじゃない

Googleが用意してくれたマシンイメージには Google が毎月 Windows Update をあてた最新に差し替えてくれているというメリットがあります。Windows Update 適用>イメージ作成を自動化してもいいと思います。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?