|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-01-20 15:39 UTC] sniper@php.net
[2003-01-20 16:33 UTC] phpbugs at sannes dot org
[2003-01-20 16:38 UTC] sniper@php.net
[2003-01-20 17:31 UTC] phpbugs at sannes dot org
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 28 21:00:01 2025 UTC |
My webserver has two ways of executing the php cgi binary, one way through suexec (cgi with #!) and another through suphp. Running the php-code: echo $_SERVER['SCRIPT_NAME'] . " -- " . $SCRIPT_NAME . " -- " . getenv('SCRIPT_NAME'); Works as expected under suexec, under suphp however SCRIPT_NAME isn't available (turns up blank). First I tought that this was an suphp issue, so I made a really simple C program that logs the arguments and the environment on execution and replaced the php-cgi binary with this (for debugging purposes). I got two fairly similar logs, and I can't for the life of me figure out what is wrong. Running with suexec: http://www.sannes.org/cgi/phpinfo.cgi Running with suphp: http://www.sannes.org/test/phpinfo.suphp (Where is SCRIPT_NAME?) Before I paste the logs and the C program, let's sum this up. suexec cgi is working suphp cgi isn't working. The suexec arg/env log: argv[0] = /usr/bin/php-cgi argv[1] = test.cgi argv[2] = test.cgi PATH=/bin:/usr/bin DOCUMENT_ROOT=/home/ace/public_html HTTP_ACCEPT=text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1 HTTP_ACCEPT_CHARSET=ISO-8859-1, utf-8;q=0.66, *;q=0.66 HTTP_ACCEPT_ENCODING=gzip, deflate, compress;q=0.9 HTTP_ACCEPT_LANGUAGE=en-us, en;q=0.66, no;q=0.33 HTTP_CONNECTION=keep-alive HTTP_HOST=www.sannes.org HTTP_KEEP_ALIVE=300 HTTP_USER_AGENT=Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030105 REMOTE_ADDR=80.202.167.189 REMOTE_PORT=59148 SCRIPT_FILENAME=/home/ace/public_html/cgi/test.cgi SERVER_ADDR=10.0.18.1 SERVER_ADMIN=hostmaster@login.sannes.org SERVER_NAME=www.sannes.org SERVER_PORT=80 SERVER_SOFTWARE=Apache/1.3.27 (Unix) (Gentoo/Linux) mod_ssl/2.8.12 OpenSSL/0.9.6g PHP/4.3.0 UNIQUE_ID=PiwgDAoAEgEAABhIFPs GATEWAY_INTERFACE=CGI/1.1 SERVER_PROTOCOL=HTTP/1.1 REQUEST_METHOD=GET QUERY_STRING= REQUEST_URI=/cgi/test.cgi SCRIPT_NAME=/cgi/test.cgi The suphp args/env log: argv[0] = php argv[1] = -c argv[2] = DOCUMENT_ROOT=/home/ace/public_html HTTP_ACCEPT=text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1 HTTP_ACCEPT_CHARSET=ISO-8859-1, utf-8;q=0.66, *;q=0.66 HTTP_ACCEPT_ENCODING=gzip, deflate, compress;q=0.9 HTTP_ACCEPT_LANGUAGE=en-us, en;q=0.66, no;q=0.33 HTTP_CONNECTION=keep-alive HTTP_HOST=www.sannes.org HTTP_KEEP_ALIVE=300 HTTP_USER_AGENT=Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030105 PATH=/bin:/usr/bin REMOTE_ADDR=80.202.167.189 REMOTE_PORT=59143 SCRIPT_FILENAME=/home/ace/public_html/test/test.suphp SERVER_ADDR=10.0.18.1 SERVER_ADMIN=hostmaster@login.sannes.org SERVER_NAME=www.sannes.org SERVER_PORT=80 SERVER_SIGNATURE=<ADDRESS>Apache/1.3.27 Server at www.sannes.org Port 80</ADDRESS> SERVER_SOFTWARE=Apache/1.3.27 (Unix) (Gentoo/Linux) mod_ssl/2.8.12 OpenSSL/0.9.6g PHP/4.3.0 UNIQUE_ID=Piwf6AoAEgEAABFnCaY GATEWAY_INTERFACE=CGI/1.1 SERVER_PROTOCOL=HTTP/1.1 REQUEST_METHOD=GET QUERY_STRING= REQUEST_URI=/test/test.suphp SCRIPT_NAME=/test/test.suphp SCRIPT_URL=/test/test.suphp PATH_TRANSLATED=/home/ace/public_html/test/test.suphp PATH_INFO=/test/test.suphp REDIRECT_SCRIPT_URL=/test/test.suphp REDIRECT_STATUS=200 REDIRECT_URL=/test/test.suphp The simple c program: #include <unistd.h> #include <stdio.h> int main(int argc, char *argv[]) { extern char **environ; int i; FILE *fh; fh = fopen("/tmp/any-php.log", "a"); for (i = 0; i<argc; ++i) fprintf(fh, "argv[%d] = %s\n", i, argv[i]); for (i = 0; environ[i]; ++i) fprintf(fh, "%s\n", environ[i]); fclose(fh); } For more details just ask, currently running Linux 2.4.18, newest apache with mod_ssl. (This is enough details isn't it?)