Re: Running PHP as CGI under apache

From: Date: Thu, 16 Aug 2001 03:17:59 +0000
Subject: Re: Running PHP as CGI under apache
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-62948@lists.php.net to get a copy of this message
> If you put this script into a file (.cgi) and give it executable > permissions, you can run it from the command line > > ------------PHP CODE START------------ > #!/usr/bin/php > > <?php > print "Hello"; > ?> > ------------PHP CODE END------------ > > and the Content-Type header is added by PHP. But when I put it in my > cgi-bin directory it would not execute from a browser - I got internal > server error. > > The error log said "Premature end of script headers." > > Has anybody been able to find a way round this problem? Running PHP NOT as > a module? You will need to use: AddType application/php-cgi .phpcgi Alias phpdir "/path/to/phpdirectory/" Action application/php-cgi "phpdir/php" Alter your file to end in .phpcgi, not .cgi .cgi is probably already taken by, errr, Perl?, and you'll just screw that up if you leave it. This definitely can be done -- I've used it to run 4 or 5 different versions of PHP simultaneously to track down a bug, using extensions like .php305 .php306 .php307 and matching AddType/Action lines. I didn't actually use Alias, but I think it's cleaner to do that. You definitely need a unique mime-type as well. You'll confuse Apache no end if you assign the same mime-types to both Module and CGI PHP. -- WARNING richard@zend.com address is an endangered species -- Use ceo@l-i-e.com Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm

« previous php.general (#62948) next »