Search code examples
phpiisiis-7windows-server-2008fastcgi

How to set the php.ini path for PHP CGI/FastCGI SAPI on Windows Server 2008 r2?


I have IIS 7.0 and two versions PHP v5 and v7 on my Microsoft Windows Server 2008 Standard 6.0 SP2. The problem is, that PHP7 or IIS tries to use the php.ini of PHP5 for IIS "websites".

So on the command line everything is fine:

X:\>php -v
PHP 7.0.2 (cli) (built: Jan  6 2016 12:59:59) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

X:\>php --ini
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File:         D:\Data\Programme\php7\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

But in the IIS Manager and in the phpinfo() output not:

IIS-website-PHP-setting

phpinfo-version-sapi-php-ini

I think, it's a PHP (cgi-fcgi SAPI) issue, not an IIS issue (but not sure).

How to set the correct php.ini for PHP CGI/FastCGI SAPI on Windows Server 2008?


Also tried it over the Registry, but that didn't help:

registry-php-IniFilePath


Solution

  • The solution of Jan Reilink seems also correct, but unfortunately I could not find out, how to apply it the right way (see this and other my comments below Jan's answer).

    Finally I got it solved over the IIS GUI:

    IIS GUI -> FastCGI Settings

    And then FastCGI Settings -> EnvironmentVariables -> PHPRC:

    IIS-FastCGI-Settings-EnvironmentVariables-PHPRC

    See also "Configure IIS to Handle PHP Requests" in the chapter "Using FastCGI to Host PHP Applications on IIS 7" of the IIS documentation.