IIS新建站点、配置应用程序池

 

#新建IIS站点,设置主机头,设置应用程序池
$domainname = "domainname"
$site_oa = "OA"
$site_oa_dir = "d:\$site_oa"
$url_owa = ($site_oa + "." + $domainname).ToLower()

New-WebAppPool -Name  $site_oa
New-Website -Name $site_oa -Port 80 -HostHeader $url_oa -PhysicalPath $site_oa_dir -ApplicationPool $site_oa
New-WebBinding -Name $site_oa -IPAddress "*" -Port 443 -HostHeader $url_oa -Protocol "https"

#修改应用程序池标识为"NetworkService"
$pollname = "Site01"
$AppPool =  Get-ItemProperty "IIS:\AppPools\$pollname"
$AppPool.processModel.identityType = "NetworkService"
$AppPool | set-item
$AppPool.processModel.identityType


#删除默认站点
Import-Module webadministration
Remove-Website -Name "Default Web Site" -ErrorAction silentlycontinue

#更改IISLog位置
$iislogdir = "$drive\IISlog"
Set-WebConfigurationProperty "/system.applicationHost/sites/siteDefaults" -name logfile.directory -value $iislogdir


#修改应用程序池队列长度
$defaultAppPool = Get-ItemProperty IIS:\AppPools\DefaultAppPool
(Get-ItemProperty IIS:\AppPools\DefaultAppPool\).queueLength
Set-ItemProperty -Path $defaultAppPool.PSPath -Name queueLength -Value 5000

  #设置OA应用程序池标识、启动模式

  $pollname = "OA"

  $AppPool = Get-ItemProperty "IIS:\AppPools\$pollname"

  $AppPool.processModel.identityType = "NetworkService"

  $AppPool | set-item

  $AppPool.processModel.identityType

  Set-ItemProperty -Path $AppPool.PSPath -Name startMode -Value "AlwaysRunning"

 

  #设置OA站点预加载为True

  $Site_mailauth = "OA"

  $Site = Get-Item IIS:\Sites\$Site_mailauth

  $Site.applicationDefaults.preloadEnabled = $true

  $Site | Set-Item -Verbose

  #设置OA站点预加载路径,解决加载数据库慢的问题,参考:https://blog.csdn.net/shunhua19881987/article/details/124269640

  Add-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$Site_mailauth" -filter "system.webServer/applicationInitialization" -name "." -value @{initializationPage='/Home'}

 

 

posted on 2022-06-28 11:27  momingliu11  阅读(320)  评论(0编辑  收藏  举报