I'm using Apache 2.4.7 and PHP 5.5.7.
I have a test.php
file in C:\web\vhosts\Symfony\web
.
The value of $_SERVER['SCRIPT_FILENAME']
is correct:
C:/web/vhosts/Symfony/web/test.php
However the value of $_SERVER['SCRIPT_NAME']
depends on how I load PHP:
If I load PHP as an Apache module, the value of $_SERVER['SCRIPT_NAME']
is:
/test.php
I'm a bit surprised that it isn't the same as SCRIPT_FILENAME
, but at least it's a correct value, I guess.
Here's how I loaded 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"
If I load PHP using mod_fcgid, the value of $_SERVER['SCRIPT_NAME']
is:
C:/test.php
Which is just wrong...
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:
Set this value to 0. You can also comment it out, or remove it altogether, since 0 is the default.
According to the documentation:
However I found that the value of
cgi.fix_pathinfo
in thephp.ini
file makes absolutely no influence as to the value of$_SERVER['SCRIPT_NAME']
: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.When
FcgidFixPathinfo
is set to1
in thehttpd.conf
file,$_SERVER['SCRIPT_NAME']
is incorrect (C:/test.php
), regardless of the value ofcgi.fix_pathinfo
in thephp.ini
file.