Skip to content

Instantly share code, notes, and snippets.

@andikrueger
Last active April 3, 2020 08:29
Show Gist options
  • Save andikrueger/e4d96ef0e31412050df6da0c1bf3943d to your computer and use it in GitHub Desktop.
Save andikrueger/e4d96ef0e31412050df6da0c1bf3943d to your computer and use it in GitHub Desktop.
Installs all basic Windows Features for IIS and disables the default IIS Pools and Site; Initial PHP Setup
$features = @("Web-Server",
"Web-Mgmt-Tools",
"web-Default-Doc",
"Web-Dir-Browsing",
"Web-Http-Errors",
"Web-Static-Content",
"Web-Http-Logging",
"web-Stat-Compression",
"web-Filtering",
"web-CGI",
"web-ISAPI-Ext",
"web-ISAPI-Filter"
)
$dependsOn = @()
$features | ForEach-Object -Process {
WindowsFeature $_ {
Name = $_
Ensure = "Present"
}
$dependsOn += "[WindowsFeature]$($_)"
}
@(
".NET v2.0" ,
".NET v2.0 Classic",
".NET v4.5",
".NET v4.5 Classic",
"Classic .NET AppPool",
"DefaultAppPool"
) | ForEach-Object -Process {
xWebAppPool "Remove-$($_.ToString().Replace(" ","").Replace(".",""))"
{
Name = $_
Ensure = "Absent"
DependsOn = $dependsOn
}
}
xWebSite RemoveDefaultWebSite
{
Name = "Default Web Site"
PhysicalPath = "C:\inetpub\wwwroot"
Ensure = "Absent"
DependsOn = $dependsOn
}
Package vcRedist {
Path = "$($SourceFolder)\VC_redist.x64.exe"
ProductId = "{6c6356fe-cbfa-4944-9bed-a9e99f45cb7a}"
Name = "Microsoft Visual C++ 2017 Redistributable (x64) - 14.11.25325"
Arguments = "/install /passive"
}
Archive PHP {
Path = "$($SourceFolder)\php-7.1.12-nts-Win32-VC14-x64.zip"
Destination = $phpDirectory
}
File PhpWinCache {
SourcePath = "$($SourceFolder)\WinCache\php_wincache.dll"
DestinationPath = "$($phpDirectory)\ext"
Type = "File"
MatchSource = $true
DependsOn = @("[Archive]PHP")
}
File PhpIni {
SourcePath = "$($SourceFolder)\php.ini"
DestinationPath = "$($phpDirectory)\php.ini"
MatchSource = $true
Force = $true
Checksum = "SHA-512"
Ensure = "Present"
DependsOn = @("[Archive]PHP")
}
xIisModule PhpHandler {
Name = "phpFastCgi"
Path = "$($phpDirectory)\php-cgi.exe"
RequestPath = "*.php"
Verb = "*"
Ensure = "Present"
ModuleType = "FastCgiModule"
DependsOn = @("[Package]vcRedist", "[Archive]PHP") + $dependsOn
}
Script FixIisModule {
GetScript = {
return @{
Result = ""
}
}
SetScript = {
Import-Module WebAdministration
Set-WebHandler phpFastCgi -Modules FastCgiModule
}
TestScript = {
Import-Module WebAdministration
$fastCgi = Get-WebHandler phpFastCgi
return $fastCgi.Modules -eq "FastCgiModule"
}
DependsOn = "[xIisModule]PhpHandler"
}
Environment PathPhp {
Name = "Path"
Value = ";$($phpDirectory)"
Ensure = "Present"
Path = $true
DependsOn = "[Archive]PHP"
}
@andikrueger
Copy link
Author

Good question - I really can't remember. I created this setup for a very restricted environment and (maybe) was not allowed to download the msi file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment