Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199807

[PHP3] Answer: running PHP3 as CGI script From: Bart Muyzer (Bart.Muyzer <email protected>)
Date: 07/22/98

Dear list,

A weeks ago I asked the question included below. Rasmus had the answer which
is very simple:

        You MUST define either doc_root or user_dir (or both) in the
        php3.ini file when running PHP3 as a CGI script.

If you don't, you'll get the behaviour as I describe in the question.

Thanks to everybody for answering!

The original question was:

> I've compiled PHP 3.0 as a CGI program for Solaris 2.6, using gcc-2.7.2 . The
> apache server version I'm using is 1.2b7.
> I used the following to configure PHP:
>
> ./configure --enable-debug=no --enable-safe-mode=yes --enable-track-vars=yes
> --enable-magic-quotes=yes --enable-bcmath=yes --enable-discard-path=yes
> --bindir=/usr/local/www/cgi-bin
>
> All compiles fine, and I moved the php binary to my cgi-bin directory.
>
> I added the following lines to apaches "srm.conf" file:
>
> AddType application/x-httpd-php3 .php3
> Action application/x-httpd-php3 /bin/php
>
> and 'kill -HUP'ed the server.
>
> I created a little script, called t.php3, containing:
>
> <HTML>
> <TITLE>This is my first PHP test</TITLE>
> <HEAD>
> </HEAD>
> <BODY>
> <I>PHP info:</I>
> <?phpinfo()?>
> </BODY
> </HTML>
>
> The problem is that when I try to "execute" this script by pointing my
> Netscape 3 browser at URL "http://www-test.azu.nl/~bmuyzer/t.php3", it looks
> like the PHP binary itself is displayed!! I get the same results when I try to
> access PHP directly by using URL ""http://www-test.azu.nl/bin/php".
>
> When I configure PHP with the "--enable-force-cgi-redirect" and put the
> resulting binary in my cgi-bin directory and then access it using URL
> "http://www-test.azu.nl/bin/php", I get a page telling me:
>
> 'Security Alert! PHP CGI cannot be accessed directly.
>
> This PHP CGI binary was compiled with force-cgi-redirect enabled. This means
> that a page will only be served up if the REDIRECT_STATUS CGI variable is set.
> This variable is set, for example, by Apache's Action directive redirect.
>
> [more text deleted]
> '
>
> And when I now try to load the t.php3 file into my browser, I get garbage
> again (that however contains the same 'Security Alert' message when I read
> carefully ;-) )
>
> Because PHP obviously runs when I try to access it directly (it then tells me
> I shouln't ;-) ) I think the problem is not that apache doesn't recognize it
> as a binary that should be run instead of displayed. So I don't understand
> what's going on.
>
>
> So I have two questions:
> 1. Why do I get garbage when I configure PHP without the
> "--enable-force-cgi-redirect" option?
> 2. What (more) should I configure in Apache to be able to use PHP configured
> *with* the "--enable-force-cgi-redirect" option (which is obviously the
> preferred path I wanna take)? Could someone please give me a cookbook
> example?
>
> Please respond to me directly (Bart.Muyzer <email protected>) as I'm not a member of this
> mailing list...
>
> Many many thanks in advance. I've been fighting this problem for 3 nights now.
> Oh, by the way, I get exacly the same results on my box at home (FreeBSD
> 2.2.1, newer gcc, newer apache -- I don't know their version numbers).

-- 
 Bart Muyzer <Bart.Muyzer <email protected>>, [WHOIS: BJM9]; University Hospital Utrecht, 
   Systems and Networking Group, P.O. Box 85500 - FAC 3.12, 3508 GA Utrecht, 
   Holland. Tel: +31-30-2509283 (w), +31-30-6052157 (h). Fax: +31-30-2542028 
                 Web: http://www.dutchworks.nl/people/bartm

-- PHP 3 Mailing List http://www.php.net/ To unsubscribe send an empty message to php3-unsubscribe <email protected> To subscribe to the digest list: php3-digest-subscribe <email protected> For help: php3-help <email protected> Archive: http://www.php.net/mailsearch.php3