Last active
December 22, 2022 05:55
-
-
Save kimboslice99/dbddb292b6c8c4215cb8d70a2825f03c to your computer and use it in GitHub Desktop.
A script to set up PHP easily
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
# Drop this script in your PHP folder with the ini & php-cgi.exe | |
$path = "$PSScriptRoot\php-cgi.exe" | |
$ini = "$PSScriptRoot\php.ini" | |
# Get Version | |
$Version = "$(./php -r 'echo PHP_VERSION;')" | |
# Create Handler | |
New-WebHandler -Name "PHP $Version" -Path "*.php" -Verb "*" -Modules FastCgiModule -ScriptProcessor "$path" -ResourceType "Either" | |
# FastCGI Settings | |
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/fastCgi" -name "." -value @{fullPath="$path";monitorChangesTo="$ini";stderrMode='ReturnGeneric500';maxInstances=8;idleTimeout=600;activityTimeout=604800;requestTimeout=7200;instanceMaxRequests=10000;protocol='NamedPipe';rapidFailsPerMinute=105} | |
# Environment Variables | |
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/fastCgi/application[@fullPath='$path']/environmentVariables" -name "." -value @{name='PHP_FCGI_MAX_REQUESTS';value='10005'} | |
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/fastCgi/application[@fullPath='$path']/environmentVariables" -name "." -value @{name='PHPRC';value="$PSScriptRoot"} | |
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/fastCgi/application[@fullPath='$path']/environmentVariables" -name "." -value @{name='PHP_FCGI_CHILDREN';value='0'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment