« Previous Next »

Thread: three different PHP sites, want individual PHP.ini for each

Last post 11-02-2009 3:57 PM by ksingla. 3 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (4 items)

Sort Posts:

  • 11-02-2009, 1:48 PM

    three different PHP sites, want individual PHP.ini for each

    I have three sites currently running on a W2K8 server under fastcgi, but they are all sharing a common php.ini, within the c:\php\php.ini file.

     I have tried to follow the directions here

    http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-70/#Per-site_PHP_configuration

    to try and "specifing PHP.INI location", but despite multiple attempts to configure the applicationHost.config file, I cannot get the three sites to each run off their own file.

     Info:

    site 1:   beta.xxxxx.com, local path to php file: c:\websites\beta.xxxxx.com\php.ini, locap path to web site files c:\websites\beta.xxxxx.com\www\

    site 2: www.yyyyy.com  , local path to php file: c:\websites\www.yyyyy.com\php.ini, locap path to web site files c:\websites\www.yyyyy.com\www\

    site 3: www.xxxxx.com  , local path to php file: c:\websites\www.xxxxx.com\php.ini, locap path to web site files c:\websites\www.xxxxx.com\www\

    So far, the only thing I can get to work is to have all three sites read one PHP.ini file from inside one of the directories  (this WORKS, but globally changes all three sites to read from the one PHP.ini file).  I need separate configs, one for each file.

            <fastCgi>
                <application fullPath="C:\PHP\php-cgi.exe" arguments="" maxInstances="4" idleTimeout="300" activityTimeout="30" requestTimeout="7000" instanceMaxRequests="10000" protocol="NamedPipe" queueLength="1000" flushNamedPipe="false" rapidFailsPerMinute="10">
                    <environmentVariables>
                        <environmentVariable name="PHPRC" value="C:\Websites\beta.xxxxx.com\php.ini" />
                    </environmentVariables>
                </application>
            </fastCgi>

    I cannot seem to get the "site 2" and "site 3" setups to work and read their own php.ini file.  If I add more entries into the <fastcgi> area for the other sites, that that typically get IIS generates errors that it can't find the right handler.

    Am going nuts here as I need to have separate configs in the php.ini files, and short of moving the sites to separate boxes am getting more grey hair by the second.

  • 11-02-2009, 2:06 PM In reply to

    • ksingla
    • Top 25 Contributor
    • Joined on 06-14-2006, 3:02 AM
    • Redmond, WA
    • Posts 863

    Re: three different PHP sites, want individual PHP.ini for each

    Hi,

    Adding 3 process pools in fastcgi section and then each site using a different handler which point to different process pool should work. Can you pls try instructions in the article again and paste the error you are getting?

    Thanks,
    Kanwal

    Follow me on twitter at http://twitter.com/kjsingla
  • 11-02-2009, 3:21 PM In reply to

    Re: three different PHP sites, want individual PHP.ini for each

    Can you please explain what you mean, by "each site using a different handler"? I've read the article multiple times and i still don't understand exactly where in the config file these configurations are to go.

     is this what you are talking about?

    a) where does this go in the config code?

    b) how do you do three different ones so that the don't conflict??

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

  • 11-02-2009, 3:57 PM In reply to

    • ksingla
    • Top 25 Contributor
    • Joined on 06-14-2006, 3:02 AM
    • Redmond, WA
    • Posts 863

    Re: three different PHP sites, want individual PHP.ini for each

    So you are clear on how to create three process pools under <fastCgi> section with different arguments and PHPRC environment variable value. For setting a site specific handler, you can paste the following configuration in web.config in site root folder.

    <configuration>
      <system.webServer>
        <handlers accessPolicy="Read,Script">
          <!-- remove is only needed if PHP handler is added at global level as well -->
          <remove name="PHP_via_FastCGI" />

          <!-- Add the site handler entry here -->      
          <add name="PHP_via_FastCGI" path ....... />
        </handlers>
      </system.webServer>
    </configuration>

    For processing request for a particular site, IIS will pick the handler section at global level (config in applicationHost.config) and then merge the handlers section in site web.config. Having different handlers entries in different site roots will make IIS pick only one PHP_via_FastCGI entry. This way three entries won't conflict with each other.

    Thanks,
    Kanwal

    Follow me on twitter at http://twitter.com/kjsingla
Page 1 of 1 (4 items)
Microsoft Communities