Pregunta

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?

¿Fue útil?

Solución

Now I know what's wrong:

FcgidFixPathinfo 1

Set this value to 0. You can also comment it out, or remove it altogether, since 0 is the default.


According to the documentation:

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.

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']:

  • When FcgidFixPathinfo is set to 0 in the httpd.conf file, $_SERVER['SCRIPT_NAME'] is correct (/test.php), regardless of the value of cgi.fix_pathinfo in the php.ini file.

  • 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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top