Hosting PHP on IIS 7 by pptfiles

VIEWS: 0 PAGES: 15

									    Hosting PHP on IIS 7.0
    Best Practices for shared hosting




                                        Microsoft®
                                        Hosting Deployment
                                        Accelerator
1
    Agenda
     PHP Setup
     FastCGI architecture
     Hosting guidance
       Multiple PHP versions
       Per-site PHP configuration
       Providing URL rewriting
       Managing CPU usage
     Summary


2
    PHP setup steps

                       • Use zip file with non-thread safe binaries
                       • Alternatively - download PHP installer
       Copy binaries



                       • fastcgi.impersonate = 1
                       • cgi.fix_pathinfo = 1
        Configure
         php.ini       • open_basedir = “C:\Websites\”


                     • Enable CGI
                     • Configure FastCGI handler mapping for *.php
       Configure IIS • Change FastCGI settings



                       • C:\php\php-cgi.exe –info
        Test that it   • http://localhost/phpinfo.php
          works




3
    FastCGI Handler Architecture

         IIS Worker Process
                              FastCGI protocol
                              over named pipes or
                              TCP

                                                    FastCGI process pool
                                                         for PHP5




                    Request
                     queue



4
    Recommended configuration
                               FastCGI Process Pool
         App Pool #1 (user1)

               Web site #1


                               FastCGI Process Pool
         App Pool #2 (user2)

               Web site #2


               …                    …
                               FastCGI Process pool
         App Pool #N (userN)

              Web site #N

5
    Recommended configuration
     Configure security isolation
       One app pool per web site
       Enable FastCGI impersonation
     Prevent failures caused by PHP recycling
       set PHP_FCGI_MAX_REQUESTS >=
       instanceMaxRequests
     For higher site density:
       use dynamicIdleThreshold
       reduce idleTimeout
       reduce maxInstances (may affect performance)



6
    Enhance your PHP hosting offer


         Allow customers to choose PHP version

         •Support both PHP 4.X and 5.X on the same server

         Provide your customers with flexibility of changing PHP configuration

         •Enable hosting of PHP apps that require tweaks to php.ini

         Easily enable sub-domains

         •Use URL rewrite module to implement sub-domains support

         Provide URL rewriting functionality

         •Expose rich set of IIS tools for creating and testing of rewrite rules




7
    Multiple PHP versions

                                Process Pool for PHP 5
          App Pool #1 (user1)

               Web site #1

                                  C:\PHP526\php-cgi.exe



                                Process Pool for PHP 4
          App Pool #2 (user2)

               Web site #2

                                     C:\PHP447\php.exe




8
     Per-site PHP configuration
     Configuring FastCGI process pool

                               Combination of fullPath and arguments uniquely
                               identify FastCGI process pool definition



      <fastCgi>
       <application fullPath="C:\PHP\php-cgi.exe" arguments="-d my.website=website1">
        <environmentVariables>
         <environmentVariable name="PHPRC" value="C:\WebSites\website1" />
        </environmentVariables>
       </application>
      </fastCgi>


                             PHPRC environment variable
                             contains path to the php.ini file


10
     Per-site PHP configuration
     Configuring Handler Mapping




      <system.webServer>
       <handlers accessPolicy="Read, Script">
        <add name="PHP via FastCGI" path="*.php"
          verb="*" modules="FastCgiModule"
          scriptProcessor="C:\PHP\php-cgi.exe|-d my.website=website2"
          resourceType="Unspecified" requireAccess="Script" />
       </handlers>
      </system.webServer>



                                Reference FastCGI process pool by
                                concatenating [fullPath]|[arguments]
11
     Providing URL rewriting




12
     Manage CPU utilization
      Windows Server Resource Manager (WSRM)
        Available in all SKU’s of WS2008
        Ensures that process gets *at least* the configured CPU
        percentage
        Kicks in only if overall CPU load is more than 70%
      IIS team tested with 4000 web sites




13
     Using WSRM




14
     Best practices summary
       Follow IIS 7.0 security isolation guidelines
       Leverage FastCGI/IIS features to enhance
       hosting offer:
          Multiple PHP versions
          Per-site PHP configuration
          URL rewriting
       Use WSRM to manage w3wp.exe and php-
       cgi.exe CPU utilization
       More information at http://learn.iis.net/page.aspx/208/fastcgi-with-php


15
16

								
To top