#19656 [Opn]: FastCGI : Wrong SCRIPT_NAME and SCRIPT_FILENAME

From: Date: Sun, 29 Sep 2002 12:22:52 +0000
Subject: #19656 [Opn]: FastCGI : Wrong SCRIPT_NAME and SCRIPT_FILENAME
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-20658@lists.php.net to get a copy of this message
ID: 19656 User updated by: elk@model-fx.com Reported By: elk@model-fx.com Status: Open Bug Type: Other web server Operating System: Linux 2.4.19 PHP Version: 4.2.3 New Comment: I don't think this hack still works for PHP < 4.2 because there is no _SERVER vars... aie... Previous Comments: ------------------------------------------------------------------------ [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 (#20658) next »