PHP as CGI script in CGI-BIN?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Keith

    #1

    PHP as CGI script in CGI-BIN?

    All:
    I am having problems trying to run some php scripts in cgi. I have Apache 2.0+ and PHP 4.3. Perl works fine
    with CGI and PHP works find as an Apache module. Whenever I attempt to run the php script through a URL with the
    cgi-bin, it asks if I want to open or download the file. Cgi files execute fine though. Can anyone think of anything I
    might be missing in any of the conf files?
    Included is an example of one of my php scripts. Thank you for any advice.

    #!/usr/bin/php -q

    <?php phpinfo(); ?>

  • Andy Hassall

    #2
    Re: PHP as CGI script in CGI-BIN?

    On Wed, 21 Sep 2005 15:24:05 GMT, cmarvelNOSPAM@n ethere.com (Keith) wrote:
    [color=blue]
    >All:
    > I am having problems trying to run some php scripts in cgi. I have Apache 2.0+ and PHP 4.3. Perl works fine
    >with CGI and PHP works find as an Apache module. Whenever I attempt to run the php script through a URL with the
    >cgi-bin, it asks if I want to open or download the file. Cgi files execute fine though. Can anyone think of anything I
    >might be missing in any of the conf files?
    > Included is an example of one of my php scripts. Thank you for any advice.
    >
    >#!/usr/bin/php -q
    >
    ><?php phpinfo(); ?>[/color]

    The -q flag suppresses the Content-type header, IIRC. You don't want to
    suppress this, you want to let PHP send it unless you are specifying one
    yourself with header().

    Also, make sure the PHP you're referring to is the CGI version of PHP - as
    there is a separate command-line version as well (the "CLI" SAPI). Having not
    had much experience running as CGI (I always use the webserver module version)
    I can't say for sure if these two are fundamentally different, but they
    certainly appear to be built separately at least in PHP 5.

    What does "php -v" say?
    --
    Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
    http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

    Comment

    • cmarvel@nethere.com

      #3
      Re: PHP as CGI script in CGI-BIN?

      Andy:
      I found what the problem was. I was using the php module rather than
      the php-cgi module. Thanks!

      Keith

      Comment

      Working...