1 / 16

Running PHP on Windows Server 2008 and IIS 7

Running PHP on Windows Server 2008 and IIS 7. Rob Cameron Developer Evangelist, Communications Sector Microsoft. 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

Download Presentation

Running PHP on Windows Server 2008 and IIS 7

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Running PHP on Windows Server 2008 and IIS 7 Rob Cameron Developer Evangelist, Communications Sector Microsoft

  2. 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 IIS7 • Deploying and managing PHP applications on IIS7 • Extending PHP applications with IIS7 • Best practices

  3. 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

  4. 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++

  5. 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

  6. FastCGI Handler Architecture FastCGI process pool for PHP5 IIS Worker Process FastCGI protocol over named pipes or TCP php-cgi.exe FastCGI process pool for PHP4 Request queue php.exe

  7. Installing FastCGI and PHP on IIS7 DEMO

  8. 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.

  9. 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.

  10. Extending Existing PHP Applications with ASP.NET in the IIS7 Integrated Pipeline DEMO

  11. 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="C:\PHP\php-cgi.exe" • maxInstances="4" • instanceMaxRequests="10000" • idleTimeout="300"/> • </fastCgi>

  12. 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="C:\PHP\php-cgi.exe" • instanceMaxRequests=“10000"> • <environmentVariables> •     <environmentVariable • name=”PHP_FCGI_MAX_REQUESTS” • value=”10000”/> •    </environmentVariables> • </application> • </fastCgi>

  13. 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="C:\PHP\php-cgi.exe" • activityTimeout=“30" • requestTimeout=“90"/> • </fastCgi>

  14. 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!

  15. Summary • FastCGI for IIS6 is now available for download! • 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

  16. 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