PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #19656 FastCGI : Wrong SCRIPT_NAME and SCRIPT_FILENAME
Submitted:29 Sep 2002 6:54am UTC Modified: 26 Nov 2002 7:58pm UTC
From:elk at model-fx dot com Assigned to:
Status:No Feedback Category:Other web server
Version:4.2.3 OS:Linux 2.4.19
Votes:48 Avg. Score:3.2 ± 1.2 Reproduced:17 of 24 (70.8%)
Same Version:9 (52.9%) Same OS:8 (47.1%)
View/Vote Add Comment Developer Edit Submission

Have you experienced this issue?
Rate the importance of this bug to you:

[29 Sep 2002 6:54am UTC] elk at model-fx dot com
When running PHP under FastCGI (with Suexec wrapper enabled), the
variables _SERVER["SCRIPT_NAME"] and _SERVER["SCRIPT_FILENAME"] are
returning the path and filename of the PHP-FCGI binary instead of the
path and filename of the current executing script, that is, the values
of _ENV["SCRIPT_NAME"] and _ENV["SCRIPT_FILENAME"] respectively. This
breaks a lot of scripts relying on just $SCRIPT_NAME and
$SCRIPT_FILENAME;

ie, when setting up this in httpd.conf :

ScriptAlias /fcgi-bin/ /usr/local/apache/bin/
<Location /fcgi-bin/>
  SetHandler fastcgi-script
</Location>
AddType application/x-httpd-php .php .php3 .php4
Action application/x-httpd-php /fcgi-bin/php.fcgi

When called from a script,
$SCRIPT_NAME becomes : /fcgi-bin/php.fcgi
$SCRIPT_FILENAME becomes : /usr/local/apache/bin/php.fcgi

Versions :
PHP 4.2.3 compiled with --with-fastcgi
mod_fastcgi 2.2.12
Apache 1.3.26

I modified sapi/fastcgi.c to register the correct _SERVER vars, and it
works OK. At line 164, add :

        php_register_variable("SCRIPT_NAME",
(SG(request_info).request_uri ? SG(request_info).request_uri:""),
track_vars_array TSRM
LS_CC);
        php_register_variable("SCRIPT_FILENAME",
(SG(request_info).path_translated ?
SG(request_info).path_translated:""), track_var
s_array TSRMLS_CC);

Best,
elk@model-fx.com
[29 Sep 2002 7:22am UTC] elk at model-fx dot com
I don't think this hack still works for PHP < 4.2 because there is no
_SERVER vars... aie...
[28 Oct 2002 10:46am UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip

[28 Oct 2002 6:51pm UTC] elk at model-fx dot com
It doesn't work :

Fatal error: input in flex scanner failed in - on line 1

Sorry... am I missing something ?

--elk
[13 Nov 2002 1:00am UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over 2 weeks, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[13 Nov 2002 12:30pm UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip

And check what flex version you have installed.
The latest CVS should warn if you have too old version.
[26 Nov 2002 7:58pm UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.

[30 May 2007 1:22am UTC] kingsizewhopper at hotmail dot com
Still experiencing this bug in php 5.2.2!
Can't this one be solved?

(centos 4.4 | apache 2.0.59 + suexec | php 5.2.2 as fastcgi)
[29 Nov 2009 3:19am UTC] reyesalejandre at gmail dot com
solicito  la  autorizacion  para la  aplicacion  e  mi  cuentas de
correo  para  poder  completar  la  difusion   de  las  practicas de
comercio.
reyesalejandre@hotmail.com
reyesalejandre@gmail.com

 Asi como  su  apoyo  tecnico para  su  alicacion  en  mi  sitio.
http://peterkingalex.spaces.live.com
[7 Dec 2009 6:33am UTC] matt dot adams at cypressinteractive dot com
Confirmed that this is still a problem using FastCGI+Apache+PHP 5.2.11.

A patch to cgi_main.c as suggested in the original comment fixes this
problem.

It would be great to see this problem fixed in later versions.

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC