#19656 [Opn->Fbk]: FastCGI : Wrong SCRIPT_NAME and SCRIPT_FILENAME

From: Date: Mon, 28 Oct 2002 16:46:11 +0000
Subject: #19656 [Opn->Fbk]: FastCGI : Wrong SCRIPT_NAME and SCRIPT_FILENAME
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-23570@lists.php.net to get a copy of this message
ID: 19656 Updated by: iliaa@php.net Reported By: elk@model-fx.com -Status: Open +Status: Feedback Bug Type: Other web server Operating System: Linux 2.4.19 PHP Version: 4.2.3 New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [2002-09-29 07:22:52] elk@model-fx.com I don't think this hack still works for PHP < 4.2 because there is no _SERVER vars... aie... ------------------------------------------------------------------------ [2002-09-29 06:54:42] elk@model-fx.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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19656&edit=1

« previous php.bugs (#23570) next »