SlideShare a Scribd company logo
Running PHP on Windows Server name title Microsoft
Session Prerequisites Familiarity with hosting PHP applications Familiarity with the IIS Web server
Session Objectives And Agenda Objectives Learn how to host existing PHP applications on IIS Learn how to take advantage of IIS7 to extend existing PHP applications with ASP.NET Agenda Running PHP applications on IIS6 and IIS7 Deploying and managing PHP applications on IIS7 Extending PHP applications with IIS7 Best practices
IIS6 Application Framework support Common Gateway Interface (CGI) for CGI and PHP applications Benefits Very simple to implement and use – single-threaded execution Disadvantages Poor performance due to high process creation cost Creates and passes request data to a new CGI process Waits for CGI process to produce response Shuts down CGI process
IIS6 Application Framework support Internet Server Application Programming Interface (ISAPI) Benefit of ISAPI Can be extremely fast when written correctly Disadvantage of ISAPI Must be thread-safe (many PHP extensions are not!) Requires development in C++
FastCGI in IIS7 FastCGI: the best of both CGI and ISAPI Enhancement to CGI protocol Web server creates FastCGI process for very first request Web server re-uses existing FastCGI process for subsequent requests Ships as part of IIS7, installed with the CGI feature Benefits of FastCGI for Windows OS Much faster than CGI because there is no process creation cost Much more stable than ISAPI because of single threaded execution environment Non-thread safe PHP build is recommended for FastCGI
FastCGI Handler Architecture IIS Worker Process Request queue FastCGI process pool for PHP5 php-cgi.exe FastCGI process pool for PHP4 php.exe FastCGI protocol over named pipes or TCP
FastCGI for IIS6 Same FastCGI functionality as in IIS7, available as a separate download for IIS6 from the Microsoft download center <add link here when we have it> Fully supported by Microsoft  Walk-throughs demonstrating how to run popular PHP applications on Windows Server  See  http://www.iis.net/php Close collaboration with Zend Technologies Improvements in PHP engine for IIS with contributions and collaboration back to PHP Community Zend Core Available for Commercially Supported PHP
PHP with CGI vs. FastCGI on IIS6
FastCGI in IIS6 and IIS7 FastCGI in IIS6 FastCGI in IIS7 Available today on Download Center Available with Longhorn Server and Vista SP1 Delivered as a separate download from Windows Server 2003. Delivered as part of IIS7. Users must install the CGI feature in IIS to enable FastCGI. ISAPI extension Native IIS7 module Resources, forums, and reference material available on IIS.NET Product help documentation, as well as resources on IIS.NET. Configured via fcgiext.ini Configured via the new XML-based configuration system in IIS7. Fully supported by Microsoft Supports PHP and other FastCGI frameworks
Installing FastCGI and PHP on IIS7
Deploying PHP applications on IIS7 Control IIS configuration for PHP applications via web.config Example: setting default document for PHP application Run PHP applications in the new IIS7 integrated pipeline with ASP.NET and other web applications Extend existing PHP applications with rich ASP.NET functionality Develop new .NET modules that run in the integrated pipeline to handle PHP requests the same way as the module handles requests for ASP.NET content.  Example: URL Rewriter that makes “pretty” URLs for PHP and ASP.NET content.
Extending PHP in the Integrated Pipeline  IIS7’s Integrated Pipeline enables ASP.NET to serve as the standard .NET extensibility mechanism for IIS7.  Provides the same familiar ASP.NET APIs and features for building web applications. ASP.NET provides a rich application framework for rapid application extensions to existing PHP applications.  Example: Adding Access Control to an existing PHP application…. Using PHP Using ASP.NET Building a custom credential store and cookie-based authentication from the ground up.  Rich membership service, built-in credential store providers, the forms authentication module, and  a set of pre-made Login controls.
Extending Existing PHP Applications with ASP.NET in the IIS7 Integrated Pipeline
Best Practices for Running PHP on IIS7 Want to ensure that a new process is created if no processes are available to handle a request? Run one instance per CPU with a minimum of 4 instances Set maxInstances to the lowest possible number under full load without consuming 100% CP Want to make sure that the existing process is recycled periodically? Set  instanceMaxRequests   (number of requests to process before recycling) as high as possible without destabilizing the app PHP process’ maximum request setting (PHP_fcgi_max_requests) has to be equal or higher than the instanceMaxRequests setting. <fastCgi> <application fullPath=&quot;C:\PHP\php-cgi.exe&quot;  maxInstances=&quot;4&quot;  instanceMaxRequests=&quot;10000&quot; idleTimeout=&quot;300&quot;/> </fastCgi>
Best Practices for Running PHP on IIS7 Want to set PHP specific environment variables in the web.config file? Use  environmentVariables  configuration setting to set PHP specific environment variables. <fastCgi> <application fullPath=&quot;C:\PHP\php-cgi.exe&quot;  instanceMaxRequests=“10000&quot;> <environmentVariables>     <environmentVariable  name=”PHP_FCGI_MAX_REQUESTS”  value=”10000”/>     </environmentVariables> </application> </fastCgi>
Best Practices for Running PHP on IIS7 Is your server under so much load that your clients are getting timeout responses? The FastCGI process will be terminated if it does not respond to FastCGI handler within specified time period.  Set the requestTimeout  (number of seconds to wait for process to handle the request) value to be higher than the activityTimeout (number of seconds to wait for any process activity) value. <fastCgi> <application fullPath=&quot;C:\PHP\php-cgi.exe&quot;  activityTimeout=“30&quot;  requestTimeout=“90&quot;/> </fastCgi>
FastCGI Process Management
FastCGI Best Practices Want to use FastCGI process security context? Application pool identity is used for FastCGI process Use fcgi.impersonate PHP setting if client impersonation is necessary Need support for FastCGI and PHP on Windows Server? http://forums.iis.net   Looking for support from the community? http://www.iis.net/php Want to ensure serviceability and patching of PHP for business critical apps? Consider Zend’s commercial offerings (Zend Core) Need FastCGI for IIS6 installations? FastCGI Extension for IIS6 is now available for download!
Summary FastCGI for IIS6 is now available for download! <insert link> FastCGI radically improves the reliability and performance for existing PHP applications on both IIS6 and IIS7 The new integrated pipeline in IIS7 introduces the ability to extend existing PHP applications with ASP.NET, as well as develop managed modules that handle requests for any web application (ASP.NET, PHP, Ruby, etc.) in the request pipeline
IIS.NET: Home for IIS Community! In-depth technical articles and samples Connect with other IIS experts on blogs & forums Free advice and assistance in forums Download center with IIS solutions

More Related Content

DOC
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web server
PDF
Presentation
PPTX
Windows Server and Fast CGI Technologies For PHP
PDF
Read me
PDF
Manual 5
PPTX
Composer | PHP Dependency Manager
PPT
Its3 Drupal
PDF
Introduction to Apache Web Services using latex
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web server
Presentation
Windows Server and Fast CGI Technologies For PHP
Read me
Manual 5
Composer | PHP Dependency Manager
Its3 Drupal
Introduction to Apache Web Services using latex

What's hot (16)

PDF
&lt;img src="../i/r_14.png" />
PDF
Nginx Essential
PDF
Apache windows
PDF
Howto: Install openQRM 5.1 on Debian Wheezy
PPTX
PHP Dependency Management with Composer
PDF
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
PPT
Utosc2007_Apache_Configuration.ppt
PPT
PHP on Windows 2008
PDF
Realtime with-websockets-2015
PDF
How%20to%20install%20PHP%20on%20Linux%20_%20laffers
ODP
Website releases made easy with the PEAR installer - Barcelona 2008
PDF
Secure PHP environment
PDF
PVS-Studio in the Clouds: Travis CI
PPTX
Http2 kotlin
PDF
APACHE WEB SERVER FOR LINUX
PDF
HTTP2:新的机遇与挑战
&lt;img src="../i/r_14.png" />
Nginx Essential
Apache windows
Howto: Install openQRM 5.1 on Debian Wheezy
PHP Dependency Management with Composer
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Utosc2007_Apache_Configuration.ppt
PHP on Windows 2008
Realtime with-websockets-2015
How%20to%20install%20PHP%20on%20Linux%20_%20laffers
Website releases made easy with the PEAR installer - Barcelona 2008
Secure PHP environment
PVS-Studio in the Clouds: Travis CI
Http2 kotlin
APACHE WEB SERVER FOR LINUX
HTTP2:新的机遇与挑战
Ad

Similar to Running PHP on Windows Technical Overview (20)

PPTX
PHP and FastCGI Performance Optimizations
PPT
Microsoft, PHP and IIS7
PPT
PHP on Windows - What's New
PPT
Wordpress On Windows
PPTX
PHP Enhancement with Windows Server 2008
PPTX
Partying with PHP on Microsoft Internet Information Services 7
PPT
IIS 6.0 and asp.net
PPTX
Advanced mechanisms for dynamic content delivery
PPTX
P H P Framework
PPT
Php Asp Net Interoperability Rc Jao
PPT
Introduction to YII framework
ODP
Scaling PHP Applications with Zend Platform
DOC
Introduction To Iis 7
PPTX
phpbenelux - Microsoft & PHP (Web Platform Installer, Bridges and Azure)
PDF
Integrating PHP With System-i using Web Services
PPTX
Building and managing applications fast for IBM i
PPTX
Wordpress on Windows
PPT
Php Presentation
PDF
Know about cake php framework with vertexplus
PHP and FastCGI Performance Optimizations
Microsoft, PHP and IIS7
PHP on Windows - What's New
Wordpress On Windows
PHP Enhancement with Windows Server 2008
Partying with PHP on Microsoft Internet Information Services 7
IIS 6.0 and asp.net
Advanced mechanisms for dynamic content delivery
P H P Framework
Php Asp Net Interoperability Rc Jao
Introduction to YII framework
Scaling PHP Applications with Zend Platform
Introduction To Iis 7
phpbenelux - Microsoft & PHP (Web Platform Installer, Bridges and Azure)
Integrating PHP With System-i using Web Services
Building and managing applications fast for IBM i
Wordpress on Windows
Php Presentation
Know about cake php framework with vertexplus
Ad

More from Wes Yanaga (12)

PPTX
Azure Platform
PDF
Windows Azure Platfrom App Fabric
PPTX
WebsiteSpark In One Slide
PPTX
Windows Azure Partner Presentation
PPT
Build Apps Using Dynamic Languages
PPT
ASPNET for PHP Developers
PPT
IE8 Dev Overview_pp2003
PPT
A Lap around Windows Internet Explorer 8_pp2003
PPT
Azure Services Platform_Partner_Briefing
PPT
Azure Services Platform Oc Event Ned
PPT
Pro Dev Briefing Irvine Wesyppt23
PPT
Live Mesh Presentation Bruno Svc
Azure Platform
Windows Azure Platfrom App Fabric
WebsiteSpark In One Slide
Windows Azure Partner Presentation
Build Apps Using Dynamic Languages
ASPNET for PHP Developers
IE8 Dev Overview_pp2003
A Lap around Windows Internet Explorer 8_pp2003
Azure Services Platform_Partner_Briefing
Azure Services Platform Oc Event Ned
Pro Dev Briefing Irvine Wesyppt23
Live Mesh Presentation Bruno Svc

Recently uploaded (20)

PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Approach and Philosophy of On baking technology
PPT
Teaching material agriculture food technology
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
cuic standard and advanced reporting.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Review of recent advances in non-invasive hemoglobin estimation
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Machine Learning_overview_presentation.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Approach and Philosophy of On baking technology
Teaching material agriculture food technology
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
A comparative analysis of optical character recognition models for extracting...
cuic standard and advanced reporting.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Review of recent advances in non-invasive hemoglobin estimation
The AUB Centre for AI in Media Proposal.docx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Spectral efficient network and resource selection model in 5G networks
MYSQL Presentation for SQL database connectivity
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Assigned Numbers - 2025 - Bluetooth® Document
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Machine Learning_overview_presentation.pptx
A Presentation on Artificial Intelligence
Dropbox Q2 2025 Financial Results & Investor Presentation

Running PHP on Windows Technical Overview

  • 1. Running PHP on Windows Server name title Microsoft
  • 2. Session Prerequisites Familiarity with hosting PHP applications Familiarity with the IIS Web server
  • 3. Session Objectives And Agenda Objectives Learn how to host existing PHP applications on IIS Learn how to take advantage of IIS7 to extend existing PHP applications with ASP.NET Agenda Running PHP applications on IIS6 and IIS7 Deploying and managing PHP applications on IIS7 Extending PHP applications with IIS7 Best practices
  • 4. IIS6 Application Framework support Common Gateway Interface (CGI) for CGI and PHP applications Benefits Very simple to implement and use – single-threaded execution Disadvantages Poor performance due to high process creation cost Creates and passes request data to a new CGI process Waits for CGI process to produce response Shuts down CGI process
  • 5. IIS6 Application Framework support Internet Server Application Programming Interface (ISAPI) Benefit of ISAPI Can be extremely fast when written correctly Disadvantage of ISAPI Must be thread-safe (many PHP extensions are not!) Requires development in C++
  • 6. FastCGI in IIS7 FastCGI: the best of both CGI and ISAPI Enhancement to CGI protocol Web server creates FastCGI process for very first request Web server re-uses existing FastCGI process for subsequent requests Ships as part of IIS7, installed with the CGI feature Benefits of FastCGI for Windows OS Much faster than CGI because there is no process creation cost Much more stable than ISAPI because of single threaded execution environment Non-thread safe PHP build is recommended for FastCGI
  • 7. FastCGI Handler Architecture IIS Worker Process Request queue FastCGI process pool for PHP5 php-cgi.exe FastCGI process pool for PHP4 php.exe FastCGI protocol over named pipes or TCP
  • 8. FastCGI for IIS6 Same FastCGI functionality as in IIS7, available as a separate download for IIS6 from the Microsoft download center <add link here when we have it> Fully supported by Microsoft Walk-throughs demonstrating how to run popular PHP applications on Windows Server See http://www.iis.net/php Close collaboration with Zend Technologies Improvements in PHP engine for IIS with contributions and collaboration back to PHP Community Zend Core Available for Commercially Supported PHP
  • 9. PHP with CGI vs. FastCGI on IIS6
  • 10. FastCGI in IIS6 and IIS7 FastCGI in IIS6 FastCGI in IIS7 Available today on Download Center Available with Longhorn Server and Vista SP1 Delivered as a separate download from Windows Server 2003. Delivered as part of IIS7. Users must install the CGI feature in IIS to enable FastCGI. ISAPI extension Native IIS7 module Resources, forums, and reference material available on IIS.NET Product help documentation, as well as resources on IIS.NET. Configured via fcgiext.ini Configured via the new XML-based configuration system in IIS7. Fully supported by Microsoft Supports PHP and other FastCGI frameworks
  • 11. Installing FastCGI and PHP on IIS7
  • 12. Deploying PHP applications on IIS7 Control IIS configuration for PHP applications via web.config Example: setting default document for PHP application Run PHP applications in the new IIS7 integrated pipeline with ASP.NET and other web applications Extend existing PHP applications with rich ASP.NET functionality Develop new .NET modules that run in the integrated pipeline to handle PHP requests the same way as the module handles requests for ASP.NET content. Example: URL Rewriter that makes “pretty” URLs for PHP and ASP.NET content.
  • 13. Extending PHP in the Integrated Pipeline IIS7’s Integrated Pipeline enables ASP.NET to serve as the standard .NET extensibility mechanism for IIS7. Provides the same familiar ASP.NET APIs and features for building web applications. ASP.NET provides a rich application framework for rapid application extensions to existing PHP applications. Example: Adding Access Control to an existing PHP application…. Using PHP Using ASP.NET Building a custom credential store and cookie-based authentication from the ground up. Rich membership service, built-in credential store providers, the forms authentication module, and a set of pre-made Login controls.
  • 14. Extending Existing PHP Applications with ASP.NET in the IIS7 Integrated Pipeline
  • 15. Best Practices for Running PHP on IIS7 Want to ensure that a new process is created if no processes are available to handle a request? Run one instance per CPU with a minimum of 4 instances Set maxInstances to the lowest possible number under full load without consuming 100% CP Want to make sure that the existing process is recycled periodically? Set instanceMaxRequests (number of requests to process before recycling) as high as possible without destabilizing the app PHP process’ maximum request setting (PHP_fcgi_max_requests) has to be equal or higher than the instanceMaxRequests setting. <fastCgi> <application fullPath=&quot;C:\PHP\php-cgi.exe&quot; maxInstances=&quot;4&quot; instanceMaxRequests=&quot;10000&quot; idleTimeout=&quot;300&quot;/> </fastCgi>
  • 16. Best Practices for Running PHP on IIS7 Want to set PHP specific environment variables in the web.config file? Use environmentVariables configuration setting to set PHP specific environment variables. <fastCgi> <application fullPath=&quot;C:\PHP\php-cgi.exe&quot; instanceMaxRequests=“10000&quot;> <environmentVariables>     <environmentVariable name=”PHP_FCGI_MAX_REQUESTS” value=”10000”/>     </environmentVariables> </application> </fastCgi>
  • 17. Best Practices for Running PHP on IIS7 Is your server under so much load that your clients are getting timeout responses? The FastCGI process will be terminated if it does not respond to FastCGI handler within specified time period. Set the requestTimeout (number of seconds to wait for process to handle the request) value to be higher than the activityTimeout (number of seconds to wait for any process activity) value. <fastCgi> <application fullPath=&quot;C:\PHP\php-cgi.exe&quot; activityTimeout=“30&quot; requestTimeout=“90&quot;/> </fastCgi>
  • 19. FastCGI Best Practices Want to use FastCGI process security context? Application pool identity is used for FastCGI process Use fcgi.impersonate PHP setting if client impersonation is necessary Need support for FastCGI and PHP on Windows Server? http://forums.iis.net Looking for support from the community? http://www.iis.net/php Want to ensure serviceability and patching of PHP for business critical apps? Consider Zend’s commercial offerings (Zend Core) Need FastCGI for IIS6 installations? FastCGI Extension for IIS6 is now available for download!
  • 20. Summary FastCGI for IIS6 is now available for download! <insert link> FastCGI radically improves the reliability and performance for existing PHP applications on both IIS6 and IIS7 The new integrated pipeline in IIS7 introduces the ability to extend existing PHP applications with ASP.NET, as well as develop managed modules that handle requests for any web application (ASP.NET, PHP, Ruby, etc.) in the request pipeline
  • 21. IIS.NET: Home for IIS Community! In-depth technical articles and samples Connect with other IIS experts on blogs & forums Free advice and assistance in forums Download center with IIS solutions