Installs all basic Windows Features for IIS and disables the default IIS Pools and Site; Initial PHP Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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" | |
} |
Thank you for the feedback. I added the PHP Configuration part.
Hello Andi,
i must say your post was very helpful. I did have a question on WinCache, any reason why you did not add the step to install it on the server as a step in the DSC.
Regards,
Sai
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
Hello Andi,
Can you please share your complete DSC script - IIS Install and Php Configuration. I am not able to connect the dots between IISInstallationDSC and phpwincache scripts.
Regards,
Sai