次の方法で共有


コマンド ラインからの IIS Express の実行

作成者: Vaidy Gopalakrishnan

概要

IIS Express は、開発者向けに最適化されたシンプルで自己完結型の IIS バージョンです。 このチュートリアルでは、IIS Express コマンド ラインを使用してサイトを実行する方法について説明します。

前提条件

このチュートリアルの手順を完了するには、次のものがインストールされている必要があります。

  • Windows XP 以降
  • IIS Express

IIS Express をダウンロードしてインストールする方法については、「IIS Express の概要」を参照してください。

コマンド ラインからの IIS Express を使用したサイトの実行

  1. コマンド プロンプトを開きます。

    このチュートリアルのコマンドを実行するために管理者ユーザー権限は必要ありません。 ただし、1024 以下の番号のポートで IIS Express を実行する場合は、管理者ユーザー権限が必要です。

  2. 次のコマンドを実行して、IIS Express インストール フォルダーに移動します。

    cd \Program Files\IIS Express
    

    または、64 ビット OS を使用している場合は、次のコマンドを実行します。

    cd \Program Files (x86)\IIS Express
    
  3. 次のコマンドを実行して、IIS Express の使用状況文字列を表示します。

    iisexpress /?
    
    IIS Express Usage:
    ------------------
    iisexpress [/config:config-file] [/site:site-name] [/siteid:site-id] [/systray:boolean] 
    iisexpress /path:app-path [/port:port-number] [/clr:clr-version] [/systray:boolean] 
    
    /config:config-file 
    The full path to the applicationhost.config file. The default value is the IISExpress8\config\applicationhost.config file that is located in the user's Documents folder.
    
    /site:site-name 
    The name of the site to launch, as described in the applicationhost.config file. 
    
    /siteid:site-id 
    The ID of the site to launch, as described in the applicationhost.config file.
    
    /path:app-path 
    The full physical path of the application to run. You cannot combine this option with the /config and related options. 
    
    /port:port-number 
    The port to which the application will bind. The default value is 8080. You must also specify the /path option. 
    
    /clr:clr-version The .NET Framework version (e.g. v2.0) to use to run the application. The default value is v4.0. You must also specify the /path option. 
    
    /systray:boolean 
    Enables or disables the system tray application. The default value is true. 
    
    /trace:debug-trace-level 
    Valid values are info or i,warning or w,error or e. 
    
    Examples: 
    iisexpress /site:WebSite1 
    This command runs WebSite1 site from the user profile configuration file.
    
    iisexpress /config:c:\myconfig\applicationhost.config 
    This command runs the first site in the specified configuration file. 
    
    iisexpress /path:c:\myapp\ /port:80 
    This command runs the site from c:\myapp folder over port 80.
    
  4. 次のいずれかを使用してサイトを実行します。

  5. サイトが実行されたら、IIS Express システム トレイを使用して管理できます。 詳細については、「Windows システム トレイを使用した Web サイトとアプリケーションの管理」を参照してください。 または、次のオプションを実行して、システム トレイを無効にすることもできます。

    /systray:false
    

構成ファイルからのサイトの実行

IIS Express と IIS では、サイト、アプリケーション プール、ハンドラーなどのグローバル設定を指定する ApplicationHost.config ファイルが使用されます。IIS Express では、既定のユーザー固有の ApplicationHost.config ファイルを使用して、多くのユーザーが他のユーザーの設定を妨げることなく、同じコンピューターを共有できます。 このファイルは、ご利用の OS に応じて、%userprofile%\Documents\IISExpress\config フォルダーまたは %userprofile%\My Documents\IISExpress\config フォルダーにあります。 構成ファイルからサイトを実行する場合は、実行するサイトを指定できます。

次のコマンドを使用できます。

  • 既定の構成ファイルで Web サイト Website1 を実行するには、以下を実行します。

    iisexpress /site:WebSite1
    
  • 既定の構成ファイルで最初の Web サイトを実行するには、以下を実行します。

    iisexpress
    
  • カスタム構成ファイルで最初の Web サイトを実行するには、以下を実行します。

    iisexpress /config:c:\myconfig\applicationhost.config
    
  • カスタム構成ファイルから MyBlog というサイトを実行するには、以下を実行します。

    iisexpress /config:c:\myconfig\applicationhost.config /site:MyBlog
    

注: /config オプションでは構成ファイルの完全なパスを指定します。 既定の構成ファイルを使用する場合は、このオプションを省略できます。 /site オプションでは構成ファイル内の特定のサイトを指定します。 このオプションを省略して、構成ファイルの最初のサイトを実行できます。

アプリケーション フォルダーからのサイトの実行

/path オプションを使用して、フォルダーから直接サイトを実行することもできます。 このオプションは、静的 HTML、ASP.NET、PHP、WCF など、あらゆる種類のアプリケーションに対して機能します。 既定では、IIS Express によってサイトが http://localhost:8080/ で実行されます。 ASP.NET などのマネージド Web サイトの場合、IIS Express では .NET 4.0 が使用されます。 /port および /clr オプションを使用して、これらの既定値をオーバーライドできます。

たとえば、次のコマンドでは、.NET 2.0 を使用して指定されたアプリケーション "myapp" を http://localhost:9090/ で実行します。

iisexpress /path:c:\myapp\ /port:9090 /clr:v2.0