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

go to bug id or search bugs for  

Bug #11430 PHP-CGI executing PHP-CGI thru Apache
Submitted:12 Jun 2001 6:49am UTC Modified: 20 Aug 2002 8:39am UTC
From:allanh at netcentralen dot dk Assigned to:
Status:Closed Category:Program Execution
Version:4.3.0-dev OS:Linux 2.4 (RH7.3 upd kernel)
View/Vote Developer Edit Submission

[12 Jun 2001 6:49am UTC] allanh at netcentralen dot dk
PHP is run as a CGI script. Error does not occur when PHP is run as
Apache module.
I have reproduced error on three different systems.

file: test.php
=== cut ===
<?
echo "Ho! ";
echo `./test`;
?>
=== uncut ===

file: test
=== cut ===
#!/usr/local/bin/php -q 
<?
echo "Ha!";
?>
=== uncut ===

When running 
php -q < test.php.
output is correct:  "Ho! Ha!"

When requesting test.php through apache, output is as follows:

Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! X-Powered-By: PHP/4.0.5 Content-type: text/html Ho!
X-Powered-By: PHP/4.0.5 Content-type: text/html Ho! X-Powered-By:
PHP/4.0.5 Content-type: text/html Ho! X-Powered-By: PHP/4.0.5
Content-type: text/html Ho! X-Powered-By: PHP/4.0.5 Content-type:
text/html Ho! 

---------------------------

PHP configure string:
./configure -with-mysql --enable-force-cgi-redirect --with-gdbm
--enable-ftp 

php.ini is empty.

Apache version: 1.3.19 (also tested 1.3.9)

Also tested FreeBSD 4.3 with Apache 1.3.19, same problem.

Also tested PHP 4.0.0 and 4.0.2, same problem.
[12 Jun 2001 1:12pm UTC] sniper@php.net
I can reproduce this with 4.0.6RC3 too.
[3 Jul 2002 7:26am UTC] sander@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately your are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

[3 Jul 2002 8:29am UTC] allanh at netcentralen dot dk
When I reported the bug I used the latest version.
I just tested again and this now it no longer terminates by itself. It
crashed the server. Error messages on the screen saying out of memory --
killed httpd.

It is a different server.
[3 Jul 2002 7:10pm UTC] sniper@php.net
I tried it too..and almost had my server crashed. 
I guess the php binary used in httpd.conf is same as
in the 'test' script?
[4 Jul 2002 1:15am UTC] allanh at netcentralen dot dk
yes
[20 Aug 2002 8:39am UTC] edink@php.net
The problem is that php-cgi reads the environmental variables set by
apache, to find the correct script to execute, etc. This means that the
php-cgi binary that is executed from the cgi script will also try to
execute the original cgi scripts.

The solution is to use php-cgi binary for executing cgi scripts through
apache and php-cli binary for executing command line scripts (including
those called withing the cgi script).

RSS feed | show source 

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