× Warning! This forum is in archival status. New contributions may not work.
[campsite-dev] php CGI-Script
  • Hi there,

    can somebody help me getting run an cgi-script written in php ?
    i used the following for test, but i recive an error:

    #!/usr/local/bin/php
    header("HTTP/1.0 200 OK");
    header("CONTENT-TYPE: text/html\r\n\r\n");
    phpinfo();
    ?>

    apache returns an error 500 (internal server error).
    error.log says:
    [Mon Aug 2 16:00:10 2004] [error] [client 192.168.255.254] malformed header
    from script. Bad header=phpinfo(): /var/www.campware/cgi-bin//test

    for me this error seems that the file is not executed, because phpinfo()
    occurs there.

    if i start the script from shell, all is fine.



    sebastian

    ------------------------------------------
    Posted to Phorum via PhorumMail
  • 4 Comments sorted by
  • Hey Sebastian

    Is there a reason why you can't just use the usual approach of letting
    apache recognise the file as a PHP script based on its extension, ie with

    AddType application/x-httpd-php .php .phtml

    Also, by default the 200 OK and Content-type headers are already added
    by PHP, unless you call it with the '-q' command line option, I think.
    Although there is the 'cli' SAPI version which doesn't do this by
    default - what version of PHP 4.xxxx are you using?

    Have you seen these?

    http://au2.php.net/manual/en/install.apache.php
    http://au2.php.net/manual/en/install.commandline.php

    When I want to use a PHP script on a webserver, I just write it, give it
    a '.php' file extension, then upload it to the document root on the
    webserver. If the server is configured correctly, that should just work,
    ie the file you are writing shouldn't need to say any more than

    phpinfo();
    ?>

    It looks like a problem with your apache config or maybe that you're
    missing the '.php' extension.

    Sebastian G
  • Hi John,

    for new image handling of campsite i want to replace "get_img" script which
    is located in /cgi-bin/. there normal .php scripts not working there, and
    additionally i cannot rename it due to compatibility with parser/templates.

    temporary i solved it with a rewrite-rule for /cgi-bin/get_img, but this is
    not the best solution.



    > -----Urspr�ngliche Nachricht-----
    > Von: campsite-dev-owner@campware.org
    > [mailto:campsite-dev-owner@campware.org]Im Auftrag von John Pye
    > Gesendet: Samstag, 7. August 2004 04:47
    > An: campsite-dev@campware.org
    > Betreff: Re: [campsite-dev] php CGI-Script
    >
    >
    > Hey Sebastian
    >
    > Is there a reason why you can't just use the usual approach of letting
    > apache recognise the file as a PHP script based on its extension, ie with
    >
    > AddType application/x-httpd-php .php .phtml
    >
    > Also, by default the 200 OK and Content-type headers are already added
    > by PHP, unless you call it with the '-q' command line option, I think.
    > Although there is the 'cli' SAPI version which doesn't do this by
    > default - what version of PHP 4.xxxx are you using?
    >
    > Have you seen these?
    >
    > http://au2.php.net/manual/en/install.apache.php
    > http://au2.php.net/manual/en/install.commandline.php
    >
    > When I want to use a PHP script on a webserver, I just write it, give it
    > a '.php' file extension, then upload it to the document root on the
    > webserver. If the server is configured correctly, that should just work,
    > ie the file you are writing shouldn't need to say any more than
    >
    > > phpinfo();
    > ?>
    >
    > It looks like a problem with your apache config or maybe that you're
    > missing the '.php' extension.
    >
    > Sebastian G�bel wrote:
    >
    > >Hi there,
    > >
    > >can somebody help me getting run an cgi-script written in php ?
    > >i used the following for test, but i recive an error:
    > >
    > >#!/usr/local/bin/php
    > > > > header("HTTP/1.0 200 OK");
    > > header("CONTENT-TYPE: text/html\r\n\r\n");
    > > phpinfo();
    > >?>
    > >
    > >apache returns an error 500 (internal server error).
    > >error.log says:
    > >[Mon Aug 2 16:00:10 2004] [error] [client 192.168.255.254]
    > malformed header
    > >from script. Bad header=phpinfo(): /var/www.campware/cgi-bin//test
    > >
    > >for me this error seems that the file is not executed, because phpinfo()
    > >occurs there.
    > >
    > >if i start the script from shell, all is fine.
    > >
    > >
    > >
    > >sebastian
    > >
    > >
    > >
    > >
    > >
    >

    ------------------------------------------
    Posted to Phorum via PhorumMail
  • Hi Sebastian,

    I thought it would be easy to write a script in PHP to retrieve the images but
    it seems is not quite, so maybe it would be easier to rewrite the old CGI in
    C++ to read the new images. So leave it for me.

    Mugur

    --- Sebastian_G
  • Hey Sebastian

    It's purely an Apache config problem that you're having, I believe. I
    thought about it... probably the script is being passed through to
    Apache verbatim, and Apache itself is throwing the error because the raw
    PHP document is not a valid HTTP response document. Take a look again at
    your file permissions. Maybe the 'apache' user doesn't have permission
    to run the php binary? Or maybe your script needs to be chmod 750, or
    something?

    JP

    It's purely a Sebastian G