Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Running PHP on Windows Technical Overview


Published on

Running PHP on Windows Technical Overview

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Running PHP on Windows Technical Overview

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