问题
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:
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:
回答1:
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:
And then 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.
回答2:
You need to set environment variables in your FastCgi configuration to host multiple PHP versions in IIS. The one you want is PHPRC:
AppCmd set config -section:system.webServer/fastCgi
/+"[fullPath='c:\php5\php-cgi.exe', arguments='-c
c:\php5\php.ini'].environmentVariables.
[name='PHPRC',value='c:\php5\php.ini']" /commit:apphost
(note the -c
argument as well)
and do the same for PHP 7, and change the path. I have this, and more, explained in my blog post https://www.saotn.org/php-wincache-on-iis/.
来源:https://stackoverflow.com/questions/38503625/how-to-set-the-php-ini-path-for-php-cgi-fastcgi-sapi-on-windows-server-2008-r2