No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

55 líneas
2.4KB

  1. [CmdletBinding()]
  2. param(
  3. [string]$SiteName = 'WscMvc',
  4. [string]$PoolName = 'WscMvc',
  5. [string]$PhysicalPath,
  6. [int]$Port = 8090
  7. )
  8. Import-Module WebAdministration
  9. if (-not $PhysicalPath) {
  10. # IIS's site root is the "public" folder only - Framework/Controllers/
  11. # tests/tools/docs/logs are siblings of it, never served. See
  12. # docs/ARCHITECTURE.md.
  13. $PhysicalPath = Join-Path (Split-Path -Parent $PSScriptRoot) 'public'
  14. }
  15. if (-not (Test-Path "IIS:\AppPools\$PoolName")) {
  16. New-WebAppPool -Name $PoolName | Out-Null
  17. Set-ItemProperty "IIS:\AppPools\$PoolName" -Name managedRuntimeVersion -Value ''
  18. Set-ItemProperty "IIS:\AppPools\$PoolName" -Name enable32BitAppOnWin64 -Value $false
  19. Write-Output "Created app pool $PoolName (64-bit, no managed code)"
  20. } else {
  21. Write-Output "App pool $PoolName already exists"
  22. }
  23. if (-not (Test-Path "IIS:\Sites\$SiteName")) {
  24. New-Website -Name $SiteName -Port $Port -PhysicalPath $PhysicalPath -ApplicationPool $PoolName | Out-Null
  25. Write-Output "Created site $SiteName on port $Port -> $PhysicalPath"
  26. } else {
  27. $existingPath = (Get-Website -Name $SiteName).PhysicalPath
  28. if ($existingPath -ne $PhysicalPath) {
  29. Set-ItemProperty "IIS:\Sites\$SiteName" -Name physicalPath -Value $PhysicalPath
  30. Write-Output "Site $SiteName already existed; updated physicalPath $existingPath -> $PhysicalPath"
  31. } else {
  32. Write-Output "Site $SiteName already exists with the correct physicalPath"
  33. }
  34. }
  35. # Default.asp needs Server.MapPath("../logs") to reach logs/, which lives
  36. # outside the "public" webroot by design. Scoped to just this site via
  37. # /commit:apphost (writes a <location path="SiteName"> block in
  38. # applicationHost.config) rather than unlocking system.webServer/asp
  39. # machine-wide, which would affect every site on the host. See
  40. # docs/DECISIONS.md for why the machine-wide unlock approach is avoided.
  41. $appcmd = "$env:windir\system32\inetsrv\appcmd.exe"
  42. & $appcmd set config $SiteName -section:system.webServer/asp "/enableParentPaths:True" /commit:apphost | Out-Null
  43. $parentPathsNow = & $appcmd list config $SiteName -section:system.webServer/asp
  44. Write-Output "enableParentPaths config: $parentPathsNow"
  45. Start-WebAppPool -Name $PoolName -ErrorAction SilentlyContinue
  46. Start-Website -Name $SiteName -ErrorAction SilentlyContinue
  47. Get-Website -Name $SiteName | Select-Object Name, State, PhysicalPath, ApplicationPool

Powered by TurnKey Linux.