PHP $ _ SERVER ['SCRIPT_NAME']通过mod_fcgid加载PHP的时候是错误的 [英] PHP $_SERVER['SCRIPT_NAME'] is wrong when loading PHP via mod_fcgid
问题描述
我使用Apache 2.4.7和PHP 5.5.7。
I'm using Apache 2.4.7 and PHP 5.5.7.
我有一个 test.php的
文件 C:\\网络\\虚拟主机\\ Symfony的\\ WEB
$的价值_ SERVER ['SCRIPT_FILENAME']
是正确的:
C:/web/vhosts/Symfony/web/test.php
但 $的价值_ SERVER ['SCRIPT_NAME']
取决于我如何加载PHP:
However the value of $_SERVER['SCRIPT_NAME']
depends on how I load PHP:
如果我加载PHP作为Apache模块, $的价值_ SERVER ['SCRIPT_NAME']
是:
/test.php
我有点惊讶,这是不一样的 SCRIPT_FILENAME
,但至少这是一个正确的值,我猜。
I'm a bit surprised that it isn't the same as SCRIPT_FILENAME
, but at least it's a correct value, I guess.
下面就是我装PHP:
LoadModule php5_module "C:/web/php-5.5.7-Win32-VC11-x86/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "C:/web/php-5.5.7-Win32-VC11-x86"
如果我使用PHP加载mod_fcgid , $的价值_ SERVER ['SCRIPT_NAME']
是:
C:/test.php
这是错误的...
Which is just wrong...
下面就是我装PHP(基于教程从ApacheLounge ):
Here's how I loaded PHP (based on a tutorial from ApacheLounge):
LoadModule fcgid_module modules/mod_fcgid.so
<IfModule fcgid_module>
FcgidIOTimeout 40
FcgidConnectTimeout 10
FcgidMaxProcesses 300
FcgidMaxProcessesPerClass 300
FcgidOutputBufferSize 64
ProcessLifeTime 0
FcgidMaxRequestsPerProcess 0
FcgidMinProcessesPerClass 0
FcgidFixPathinfo 1
FcgidProcessLifeTime 0
FcgidZombieScanInterval 20
FcgidMaxRequestLen 536870912
FcgidIOTimeout 120
FcgidTimeScore 3
FcgidPassHeader Authorization
FcgidInitialEnv PHPRC "C:\\web\\php-5.5.7-Win32-VC11-x86"
FcgidInitialEnv PATH "C:\\web\\php-5.5.7-Win32-VC11-x86;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;"
FcgidInitialEnv SystemRoot "C:\\Windows"
FcgidInitialEnv SystemDrive "C:"
FcgidInitialEnv TEMP "C:\\WINDOWS\\TEMP"
FcgidInitialEnv TMP "C:\\WINDOWS\\TEMP"
FcgidInitialEnv windir "C:\\WINDOWS"
<Files ~ "\.php$">
Options Indexes FollowSymLinks ExecCGI
AddHandler fcgid-script .php
FcgidWrapper "C:/web/php-5.5.7-Win32-VC11-x86/php-cgi.exe" .php
</Files>
</IfModule>
有什么不对的安装?
What's wrong with this setup?
推荐答案
现在我知道什么是错的:
Now I know what's wrong:
FcgidFixPathinfo 1
此值设置为0。你也可以将其注释掉,或者干脆删除它,因为0是默认的。
Set this value to 0. You can also comment it out, or remove it altogether, since 0 is the default.
按照文档:
此指令启用特殊处理SCRIPT_NAME允许PHP提供额外的路径信息。 FcgidFixPathinfo的设置应反映cgi.fix_pathinfo在php.ini中设置。
This directive enables special SCRIPT_NAME processing which allows PHP to provide additional path information. The setting of FcgidFixPathinfo should mirror the cgi.fix_pathinfo setting in php.ini.
不过,我发现,的cgi.fix_pathinfo值
在的php.ini
文件完全不会有什么影响力到 $的价值_ SERVER ['SCRIPT_NAME']
:
However I found that the value of cgi.fix_pathinfo
in the php.ini
file makes absolutely no influence as to the value of $_SERVER['SCRIPT_NAME']
:
-
在
FcgidFixPathinfo
在的httpd.conf <设置为
0
/ code>文件,$ _ SERVER ['SCRIPT_NAME']
是正确的(/test.php
),无论的cgi.fix_pathinfo
在的php.ini
文件的价值。
When
FcgidFixPathinfo
is set to0
in thehttpd.conf
file,$_SERVER['SCRIPT_NAME']
is correct (/test.php
), regardless of the value ofcgi.fix_pathinfo
in thephp.ini
file.
在 FcgidFixPathinfo
在的httpd.conf <设置为
1
/ code>文件, $ _ SERVER ['SCRIPT_NAME']
不正确( C:/test.php
),无论的cgi.fix_pathinfo
在的php.ini
文件的价值。
When FcgidFixPathinfo
is set to 1
in the httpd.conf
file, $_SERVER['SCRIPT_NAME']
is incorrect (C:/test.php
), regardless of the value of cgi.fix_pathinfo
in the php.ini
file.
这篇关于PHP $ _ SERVER ['SCRIPT_NAME']通过mod_fcgid加载PHP的时候是错误的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!