What you need
- Microsoft Visual C++ 2008 Redistributable Package (x64)
- PHP 5.4.0 - Non Thread Safe Build
- Some zip software to extract the files (e.g. 7-Zip)
Install Microsoft Visual C++ 2008 Redistributable Package (x64) and copy the contents from the php zipped file to C:\PHP.
Installing IIS and CGI (FastCGI)
We use DISM (Deployment Image Servicing and Management) to enable IIS feature in Server-Core. The command is:
Start /WAIT DISM /Online /Enable-Feature /FeatureName:IIS-WebServerManagementTools /FeatureName:IIS-ManagementConsole /FeatureName:IIS-WebServerRole /FeatureName:IIS-WebServer /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-StaticContent /FeatureName:IIS-DefaultDocument /FeatureName:IIS-DirectoryBrowsing /FeatureName:IIS-HttpErrors /FeatureName:IIS-HealthAndDiagnostics /FeatureName:IIS-HttpLogging /FeatureName:IIS-Performance /FeatureName:IIS-HttpCompressionStatic /FeatureName:IIS-Security /FeatureName:IIS-RequestFiltering /FeatureName:IIS-CGI
For the bulk of the command, it is to basically enable IIS 8 with common features. The only additional feature is IIS-CGI which is required for PHP.
Configuring PHP
Create a copy of php.ini from php.ini-production. As per the manual, follow the section on Changing the php.ini file
Configuring IIS for PHP
The following are the commands to configure IIS for PHP and these are derived from the PHP Manual at http://php.net/manual/en/install.windows.iis7.php.
%windir%\system32\inetsrv\appcmd.exe set config /section:system.webServer/fastCGI ^/+[fullPath='c:\PHP\php-cgi.exe']
%windir%\system32\inetsrv\appcmd.exe set config /section:system.webServer/handlers ^/+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='c:\PHP\php-cgi.exe',resourceType='Either']
%windir%\system32\inetsrv\appcmd.exe set config ^-section:system.webServer/defaultDocument /+"files.[value='index.php']" ^/commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^/[fullPath='c:\php\php-cgi.exe'].instanceMaxRequests:10000
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^/+[fullPath='C:\php\php-cgi.exe'].environmentVariables.^[name='PHP_FCGI_MAX_REQUESTS',value='10000']
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^/[fullPath='C:\php\php-cgi.exe',arguments=''].activityTimeout:"90" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^/[fullPath='C:\php\php-cgi.exe',arguments=''].requestTimeout:"90" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^/+[fullPath='C:\php\php-cgi.exe',arguments=''].environmentVariables.^[name='PHPRC',value='C:\php\php.ini'] /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config /section:system.webServer/handlers ^/+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='c:\PHP\php-cgi.exe',resourceType='Either']
%windir%\system32\inetsrv\appcmd.exe set config ^-section:system.webServer/defaultDocument /+"files.[value='index.php']" ^/commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^/[fullPath='c:\php\php-cgi.exe'].instanceMaxRequests:10000
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^/+[fullPath='C:\php\php-cgi.exe'].environmentVariables.^[name='PHP_FCGI_MAX_REQUESTS',value='10000']
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^/[fullPath='C:\php\php-cgi.exe',arguments=''].activityTimeout:"90" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^/[fullPath='C:\php\php-cgi.exe',arguments=''].requestTimeout:"90" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^/+[fullPath='C:\php\php-cgi.exe',arguments=''].environmentVariables.^[name='PHPRC',value='C:\php\php.ini'] /commit:apphost
Testing
At C:\inetpub\wwwroot, create index.php and enter the following codes:
<?php
phpinfo();
?>
phpinfo();
?>
Finally, go to the web browser and browse http://{servername}/index.php. Once you see the PHP info like the picture below, the setup is complete.
No comments:
Post a Comment