php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19656 FastCGI : Wrong SCRIPT_NAME and SCRIPT_FILENAME
Submitted: 2002-09-29 06:54 UTC Modified: 2002-11-26 19:58 UTC
Votes:64
Avg. Score:3.4 ± 1.2
Reproduced:26 of 35 (74.3%)
Same Version:12 (46.2%)
Same OS:12 (46.2%)
From: elk at model-fx dot com Assigned:
Status: No Feedback Package: Other web server
PHP Version: 4.2.3 OS: Linux 2.4.19
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
50 - 40 = ?
Subscribe to this entry?

 
 [2002-09-29 06:54 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-29 07:22 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...
 [2002-10-28 10:46 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


 [2002-10-28 18:51 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
 [2002-11-13 01:00 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".
 [2002-11-13 12:30 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.

 [2002-11-26 19:58 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.


 [2007-05-30 01:22 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)
 [2009-11-29 03:19 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
 [2009-12-07 06:33 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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 11:01:28 2024 UTC