모든 사이트 <사이트에 대한 기본 설정디폴트>

개요

요소는 <siteDefaults> 서버의 모든 사이트에 대한 기본 설정을 지정합니다. 이러한 설정은 IIS 7 이상의 스키마 기본값과 다른 모든 웹 사이트에 대한 옵션을 지정하려는 경우에 유용합니다.

참고

섹션과 <sites> 특정 사이트의 섹션에서 동일한 특성 또는 자식 요소가 구성된 <siteDefaults> 경우 섹션의 <sites> 구성이 해당 사이트에 사용됩니다.

호환성

버전 참고
IIS 10.0 <siteDefaults> 요소가 IIS 10.0에서 수정되지 않았습니다.
IIS 8.5 <siteDefaults> 요소가 IIS 8.5에서 수정되지 않았습니다.
IIS 8.0 <siteDefaults> 요소가 IIS 8.0에서 수정되지 않았습니다.
IIS 7.5 <siteDefaults> 요소가 IIS 7.5에서 수정되지 않았습니다.
IIS 7.0 <siteDefaults> 요소의 <sites> 요소는 IIS 7.0에서 도입되었습니다.
IIS 6.0 요소는 <siteDefaults> IIS 6.0 메타베이스의 W3SVC 수준에서 기본 웹 사이트 옵션과 유사합니다.

설치 프로그램

<siteDefaults> 요소의 <sites> 요소는 IIS 7 이상의 기본 설치에 포함됩니다.

방법

서버에 대한 사이트 기본값을 구성하는 방법

  1. IIS(인터넷 정보 서비스) 관리자를 엽니다.

    • Windows Server 2012 또는 Windows Server 2012 R2를 사용하는 경우:

      • 작업 표시줄에서 서버 관리자 클릭하고 도구를 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 클릭합니다.
    • Windows 8 또는 Windows 8.1 사용하는 경우:

      • Windows 키를 누른 채로 문자 X를 누른 다음 제어판 클릭합니다.
      • 관리 도구를 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
    • Windows Server 2008 또는 Windows Server 2008 R2를 사용하는 경우:

      • 작업 표시줄에서 시작을 클릭하고 관리 도구를 가리킨 다음 IIS(인터넷 정보 서비스) 관리자를 클릭합니다.
    • Windows Vista 또는 Windows 7을 사용하는 경우:

      • 작업 표시줄에서 시작을 클릭한 다음 제어판 클릭합니다.
      • 관리 도구를 두 번 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
  2. 연결 창에서 서버 이름을 확장한 다음 사이트 노드를 클릭합니다.

  3. 서버의 사이트 창에서 작업 창에서 웹 사이트 기본값 설정...을 클릭합니다.
    기본 웹 사이트가 나열된 사이트 창을 보여 주는 스크린샷

  4. 웹 사이트 기본값 대화 상자에서 모든 웹 사이트에 대한 기본 옵션을 지정한 다음 확인을 클릭합니다.

    일반 노드가 확장된 웹 사이트 기본값 대화 상자를 보여 주는 스크린샷

구성

특성

attribute Description
id 선택적 uint 특성입니다.

사이트를 만들 때 IIS에서 할당하는 임의의 숫자 식별자를 지정합니다.

기본 웹 사이트의 번호는 1입니다. 여러 숫자로 구성될 수 있는 다른 웹 사이트 서버 할당 번호입니다.
name 선택적 문자열 특성입니다.

웹 사이트를 고유하게 식별하는 이름(예: "Contoso HR Forms")을 지정합니다.
serverAutoStart 선택적 부울 특성입니다.

관리 서비스가 시작될 때 사이트를 자동으로 시작할지 여부를 지정합니다.

기본값은 true입니다.

자식 요소

요소 Description
bindings 선택적 요소입니다.

사이트에 액세스하기 위한 기본 바인딩을 지정합니다.
ftpServer 선택적 요소입니다.

FTP 사이트의 기본 설정을 지정합니다.

참고: 이렇게 하려면 FTP 7.0 또는 FTP 7.5를 설치해야 합니다.
limits 선택적 요소입니다.

대역폭의 양, 연결 수 또는 사이트 연결 시간을 제한하도록 기본 설정을 구성합니다.
logFile 선택적 요소입니다.

사이트에 대한 로그 파일의 처리 및 스토리지에 대한 기본 설정을 구성합니다.
traceFailedRequestsLogging 선택적 요소입니다.

사이트에 대한 실패한 요청 추적을 로깅하기 위한 기본 설정을 지정합니다.

구성 샘플

다음 구성 샘플은 IIS 7에 대한 기본 limits, logFile, traceFailedRequestsLogging, bindingsftpServer 옵션을 지정합니다.

<system.applicationHost>
   <sites>
      <siteDefaults>
         <logFile logFormat="W3C"
            directory="%SystemDrive%\inetpub\logs\LogFiles"
            enabled="true" />
         <traceFailedRequestsLogging enabled="true"
            directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles"
            maxLogFiles="20" />
         <limits connectionTimeout="00:01:00" />
         <ftpServer serverAutoStart="true" />
         <bindings>
            <binding protocol="http" bindingInformation="127.0.0.1:8080:" />
         </bindings>
      </siteDefaults>
   </sites>
</system.applicationHost>

샘플 코드

다음 코드 샘플은 IIS 7에 대한 기본 limits, logFile, traceFailedRequestsLogging, bindingsftpServer 옵션을 구성합니다.

AppCmd.exe

appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.limits.connectionTimeout:"00:02:00" /commit:apphost

appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.logFile.enabled:"True" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.logFile.logFormat:"W3C" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.logFile.directory:"%SystemDrive%\inetpub\logs\LogFiles" /commit:apphost

appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.traceFailedRequestsLogging.enabled:"True" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.traceFailedRequestsLogging.directory:"%SystemDrive%\inetpub\logs\FailedReqLogFiles" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.traceFailedRequestsLogging.maxLogFiles:"20" /commit:apphost

appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.bindings.[protocol='http',bindingInformation='*:8080:contoso.com'].bindingInformation:"127.0.0.1:8080:" /commit:apphost

appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.serverAutoStart:"True" /commit:apphost

참고

AppCmd.exe 사용하여 이러한 설정을 구성할 때 commit 매개 변수 apphost 를 로 설정해야 합니다. 그러면 구성 설정이 ApplicationHost.config 파일의 적절한 위치 섹션에 커밋됩니다.

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
{
   private static void Main()
   {
      using (ServerManager serverManager = new ServerManager())
      {
         Configuration config = serverManager.GetApplicationHostConfiguration();
         ConfigurationSection sitesSection = config.GetSection("system.applicationHost/sites");
         ConfigurationElement siteDefaultsElement = sitesSection.GetChildElement("siteDefaults");

         ConfigurationElement limitsElement = siteDefaultsElement.GetChildElement("limits");
         limitsElement["connectionTimeout"] = TimeSpan.Parse("00:02:00");

         ConfigurationElement logFileElement = siteDefaultsElement.GetChildElement("logFile");
         logFileElement["logFormat"] = @"W3C";
         logFileElement["directory"] = @"%SystemDrive%\inetpub\logs\LogFiles";
         logFileElement["enabled"] = true;

         ConfigurationElement traceFailedRequestsLoggingElement = siteDefaultsElement.GetChildElement("traceFailedRequestsLogging");
         traceFailedRequestsLoggingElement["enabled"] = true;
         traceFailedRequestsLoggingElement["directory"] = @"%SystemDrive%\inetpub\logs\FailedReqLogFiles";
         traceFailedRequestsLoggingElement["maxLogFiles"] = 20;

         ConfigurationElementCollection bindingsCollection = siteDefaultsElement.GetCollection("bindings");
         ConfigurationElement bindingElement = bindingsCollection.CreateElement("binding");
         bindingElement["protocol"] = @"http";
         bindingElement["bindingInformation"] = @"127.0.0.1:8080:";
         bindingsCollection.Add(bindingElement);

         ConfigurationElement ftpServerElement = siteDefaultsElement.GetChildElement("ftpServer");
         ftpServerElement["serverAutoStart"] = true;

         serverManager.CommitChanges();
      }
   }
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample

   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetApplicationHostConfiguration
      Dim sitesSection As ConfigurationSection = config.GetSection("system.applicationHost/sites")
      Dim siteDefaultsElement As ConfigurationElement = sitesSection.GetChildElement("siteDefaults")

      Dim limitsElement As ConfigurationElement = siteDefaultsElement.GetChildElement("limits")
      limitsElement("connectionTimeout") = TimeSpan.Parse("00:02:00")

      Dim logFileElement As ConfigurationElement = siteDefaultsElement.GetChildElement("logFile")
      logFileElement("logFormat") = "W3C"
      logFileElement("directory") = "%SystemDrive%\inetpub\logs\LogFiles"
      logFileElement("enabled") = True

      Dim traceFailedRequestsLoggingElement As ConfigurationElement = siteDefaultsElement.GetChildElement("traceFailedRequestsLogging")
      traceFailedRequestsLoggingElement("enabled") = True
      traceFailedRequestsLoggingElement("directory") = "%SystemDrive%\inetpub\logs\FailedReqLogFiles"
      traceFailedRequestsLoggingElement("maxLogFiles") = 20

      Dim bindingsCollection As ConfigurationElementCollection = siteDefaultsElement.GetCollection("bindings")
      Dim bindingElement As ConfigurationElement = bindingsCollection.CreateElement("binding")
      bindingElement("protocol") = "http"
      bindingElement("bindingInformation") = "127.0.0.1:8080:"
      bindingsCollection.Add(bindingElement)

      Dim ftpServerElement As ConfigurationElement = siteDefaultsElement.GetChildElement("ftpServer")
      ftpServerElement("serverAutoStart") = true

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST");
var siteDefaultsElement = sitesSection.ChildElements.Item("siteDefaults");

var limitsElement = siteDefaultsElement.ChildElements.Item("limits");
limitsElement.Properties.Item("connectionTimeout").Value = "00:02:00";

var logFileElement = siteDefaultsElement.ChildElements.Item("logFile");
logFileElement.Properties.Item("logFormat").Value = "W3C";
logFileElement.Properties.Item("directory").Value = "%SystemDrive%\\inetpub\\logs\\LogFiles";
logFileElement.Properties.Item("enabled").Value = true;

var traceFailedRequestsLoggingElement = siteDefaultsElement.ChildElements.Item("traceFailedRequestsLogging");
traceFailedRequestsLoggingElement.Properties.Item("enabled").Value = true;
traceFailedRequestsLoggingElement.Properties.Item("directory").Value = "%SystemDrive%\\inetpub\\logs\\FailedReqLogFiles";
traceFailedRequestsLoggingElement.Properties.Item("maxLogFiles").Value = 20;

var bindingsCollection = siteDefaultsElement.ChildElements.Item("bindings").Collection;
var bindingElement = bindingsCollection.CreateNewElement("binding");
bindingElement.Properties.Item("protocol").Value = "http";
bindingElement.Properties.Item("bindingInformation").Value = "127.0.0.1:8080:";
bindingsCollection.AddElement(bindingElement);

var ftpServerElement = siteDefaultsElement.ChildElements.Item("ftpServer");
ftpServerElement.Properties.Item("serverAutoStart").Value = true;

adminManager.CommitChanges();

VBScript

Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST")
Set siteDefaultsElement = sitesSection.ChildElements.Item("siteDefaults")

Set limitsElement = siteDefaultsElement.ChildElements.Item("limits")
limitsElement.Properties.Item("connectionTimeout").Value = "00:02:00"

Set logFileElement = siteDefaultsElement.ChildElements.Item("logFile")
logFileElement.Properties.Item("logFormat").Value = "W3C"
logFileElement.Properties.Item("directory").Value = "%SystemDrive%\inetpub\logs\LogFiles"
logFileElement.Properties.Item("enabled").Value = True

Set traceFailedRequestsLoggingElement = siteDefaultsElement.ChildElements.Item("traceFailedRequestsLogging")
traceFailedRequestsLoggingElement.Properties.Item("enabled").Value = True
traceFailedRequestsLoggingElement.Properties.Item("directory").Value = "%SystemDrive%\inetpub\logs\FailedReqLogFiles"
traceFailedRequestsLoggingElement.Properties.Item("maxLogFiles").Value = 20

Set bindingsCollection = siteDefaultsElement.ChildElements.Item("bindings").Collection
Set bindingElement = bindingsCollection.CreateNewElement("binding")
bindingElement.Properties.Item("protocol").Value = "http"
bindingElement.Properties.Item("bindingInformation").Value = "127.0.0.1:8080:"
bindingsCollection.AddElement(bindingElement)

Set ftpServerElement = siteDefaultsElement.ChildElements.Item("ftpServer")
ftpServerElement.Properties.Item("serverAutoStart").Value = True

adminManager.CommitChanges()