php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24305 PHP cannot find script when called as CGI
Submitted: 2003-06-23 21:11 UTC Modified: 2003-07-07 06:08 UTC
From: ciaraldi at ciaraldi dot com Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 4.3.2 OS: Red Hat Linux 9
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ciaraldi at ciaraldi dot com
New email:
PHP Version: OS:

 

 [2003-06-23 21:11 UTC] ciaraldi at ciaraldi dot com
Description:
------------
I had been running an old PHP (4.2.1) on my Linux box. When I upgraded to Red Hat 9, the old PHP binary immediately crashed, probably due to library changes. I downloaded PHP 4.3.2 and it compiled and installed fine. But when I tried to run PHP scripts as CGI under Apache 1.3.27 (the same scripts that ran fine before, and the same version of Apache, with the same INI files for both PHP and Apache), PHP gave the message "No input file specified." It seems that Apache passes the name of the script to PHP as a command-line argument, and this version of PHP is not looking for it there. I managed to patch cgi_main.c so it works, but I am not sure that I have not broken something else. See the next box for the patched code; I changed it in two places, marked with a comment which says "HACK".

Reproduce code:
---------------
Here is the patched code:

http://poppy.ind.wpi.edu/~ciaraldi/cgi_main.c

Typical script:

#!/usr/local/bin/php
<?php
print("Hello");
?>


Expected result:
----------------
Hello

Actual result:
--------------
No input file specified. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-23 21:56 UTC] sniper@php.net
Setup your apache correctly and it works.

 [2003-06-24 12:24 UTC] ciaraldi at ciaraldi dot com
Can you be more specific? My Apache setup is the same as it has been for the last year, and PHP 4.2.1 worked fine with it. Is there a change to how Apache should be set up because of changes in PHP?
 [2003-07-05 14:04 UTC] ciaraldi at ciaraldi dot com
Does anyone have any further ideas on this?
Specifically, PHP 4.3.2 looks at various environment variables to decide if it is being called as CGI, rather than being run directly from the shell. When it gets invoked by Apache, PHP decides it is being called as CGI, then looks in the environment variable PATH_TRANSLATED for the name of the script file. My Apache does not fill in this environment variable. Do I have to configure Apache to do this? As I mentioned earlier, this is the same Apache with the same httpd.conf file. The old PHP 4.2.1 worked fine with it, but 4.3.2 does not.
 [2003-07-07 06:08 UTC] sniper@php.net
Leave the #! line out and configure Apache correctly.
(RTFM how to do it)

Ask further SUPPORT questions elsewhere, this is not a bug.

 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC