_SERVER[“PATH”] 不是从 FcgidInitialEnv PATH 设置的


_SERVER["PATH"] not being set from FcgidInitialEnv PATH

我正在使用 PHP 5.4.20、Apache 2.4.6 VC10 和 FastCGI 2.3.9 在 Windows 7 机器上设置一个新的 PHP 环境。

在我的httpd.conf中,我加载了FastCGI模块,并设置了PATH

LoadModule fcgid_module modules/mod_fcgid.so
FcgidInitialEnv PATH "c:/wamp/bin/php/php5.4.20;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;"
FcgidMaxRequestsPerProcess 1000 
FcgidMaxProcesses 50
FcgidMaxRequestLen 1073741824
FcgidBusyTimeout 360
FcgidIOTimeout 360
FcgidInitialEnv PHPRC "c:/wamp/bin/php/php5.4.20"
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
AddHandler fcgid-script .php
FcgidWrapper "c:/wamp/bin/php/php5.4.20/php-cgi.exe" .php

但是,在查看 phpinfo() 时,环境路径是根据上面的配置设置的,但_SERVER["PATH"] 似乎是从 cmd 设置的。

如何强制_SERVER["路径"]与环境路径相同?

要在 Apache 中覆盖 _SERVER["PATH"],即使使用 FastCGI,也需要使用 SetEnv PATH。

SetEnv PATH "c:/wamp/bin/php/php5.4.20;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;"