php4-cgi --> internal server errror (solution)

Lin Jianfong ljfong at hotmail.com
Sat Aug 30 16:22:35 PDT 2003


Yeah, I know it's odd. I had different problem from what you had, but after 
building php by hand (not using portinstall), it worked perfectly. I didn't 
check which of the default option turned on by the port caused my problem 
though. My problem was when apache tried to run php compiled as cgi from 
port, for some reason it uses php to parse the php cgi module itself which I 
thought was funny and weird.

This is one of the few things you can't fully rely on ports because the 
application is very specialized in this case (the mapserver + mapscript) I 
think.

I wonder if anyone is working on the port of UMN Mapserver to FreeBSD port 
system as one of GIS application ? But seeing the thing is such a huge pain 
to configure, I'm not sure if anyone is willing to do it ;)


>From: "Benjamin Thelen (CCGIS)" <thelen at ccgis.de>
>To: ljfong at hotmail.com
>CC: freebsd-questions at freebsd.org,luke at foolishgames.com
>Subject: Re: php4-cgi --> internal server errror (solution)
>Date: Sat, 30 Aug 2003 23:06:49 +0200 (CEST)
>MIME-Version: 1.0
>Received: from vogon.ccgis.de ([212.79.172.106]) by 
>mc9-f42.bay6.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Sat, 30 Aug 
>2003 14:11:09 -0700
>Received: from amavis by vogon.ccgis.de with virus-scanned (Exim 3.35 #1 
>(Debian))id 19tDBU-000412-00for <ljfong at hotmail.com>; Sat, 30 Aug 2003 
>23:23:00 +0200
>Received: from center.sz ([192.168.1.20] helo=center.shared)by 
>vogon.ccgis.de with esmtp (Exim 3.35 #1 (Debian))id 19tDBR-00040u-00; Sat, 
>30 Aug 2003 23:22:57 +0200
>Received: from localhost ([127.0.0.1] helo=center)by center.shared with 
>smtp (Exim 3.35 #1 (Debian))id 19tCvp-0000K9-00; Sat, 30 Aug 2003 23:06:49 
>+0200
>Received: from 192.168.2.109        (SquirrelMail authenticated user 
>thelen)        by vogon.ccgis.de with HTTP;        Sat, 30 Aug 2003 
>23:06:49 +0200 (CEST)
>X-Message-Info: JGTYoYF78jHPQtCuKTXOg+REQOjKFQsH
>X-Scanned-By: AMaViS-ng at Geo-Consortium Bonn
>Message-ID: <3470.192.168.2.109.1062277609.squirrel at vogon.ccgis.de>
>In-Reply-To: <Law15-F67GVoX3D8fhV0001753e at hotmail.com>
>References: <Law15-F67GVoX3D8fhV0001753e at hotmail.com>
>User-Agent: SquirrelMail/1.4.1
>X-Priority: 3
>Importance: Normal
>Return-Path: thelen at ccgis.de
>X-OriginalArrivalTime: 30 Aug 2003 21:11:09.0710 (UTC) 
>FILETIME=[3C032AE0:01C36F3B]
>
> > Hi,
> >
> > I think I know what you're talking about, it's the UMN Mapserver for GIS
> > application. Basically it's the php-mapscript part which needs php to be
> > compiled as cgi. It's a wonderful open source GIS app which works very
> > nice
> > and very stable once configured correctly but it's a major pain in the
> > butt
> > to get it right.
> >
> > As for the internal server error "premature end of script header", it
> > could
> > be either one of the many reasons :
> > - the http header is not properly generated.
> > - wrong permission
> > - wrong directory path
> > - apache port is screwed.
> > - php4-cgi port is screwed.
> > - and some other reasons unknown.
> >
> > Try writing a simple php script which contains <?php phpinfo() ?> and 
>cat
> > it
> > through the php binary in your cgi-bin. See if it generates proper HTTP
> > header + all the config stuffs correctly. I upgraded to php4.3.3rc4 from
> > the
> > port on my own box and I have different problem altogether. The last
> > working
> > version of php compiled as cgi for me is from 4.3.0 version, that is, 
>not
> > installing from port but by hand instead (tar xzvf, config,...manually).
> > So
> > try by hand as well, and see if anything changes. You do have a backup
> > copy
> > of last working php-cgi binary, don't you ?
> >
> > Sorry can't help any farther but I share your pain man.
> >
> > Date: Mon, 25 Aug 2003 21:12:08 +0200 (CEST)
> > From: "Benjamin Thelen (CCGIS)" <thelen at ccgis.de>
> > Subject: php4-cgi --> internal server errror
> > To: freebsd-questions at freebsd.org
> > Message-ID: <4885.192.168.2.109.1061838728.squirrel at vogon.ccgis.de>
> > Content-Type: text/plain;charset=iso-8859-1
> >
> > Hi,
> >
> > sorry, I've already posted this into the German user list, but as I am
> > still completely stuck I hope to find some more hints/help here.
> >
> > Systems:
> > FreeBSD 4.7 (mod_php4 - a little changed)& 4.8 (php4-cgi - the latest)
> > Apache 1.3.27 and 28
> >
> >
> >
> > We need to run php as cgi, because of the requirements of software we 
>run
> > (called umn-mapserver - if somebody knows). Half a year ago I basically
> > followed the instructions I found on the umn-mapserver wiki-pages:
> >
> > I quote, that's shorter:
> > (http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PHPMapScriptCGI)
> >
> > <quote>
> > PHP's default 'configure' behavior is to build a 'php' CGI executable.
> > It's the --with-apxs and/or --with-apache PHP configure options that
> > enable PHP to be built as an Apache DSO.
> >
> > ...to build PHP as a CGI ... don't provide the --with-apxs or
> > --with-apache switch to the PHP configure.
> >
> > Then once you have a 'php' executable, copy it to your server's cgi-bin
> > directory and add to your httpd.conf:
> >
> >
> >   AddType?  application/x-httpd-php .php3
> >   AddType?  application/x-httpd-php .phtml
> >   AddType?  application/x-httpd-php .php
> >
> >
> >   Action application/x-httpd-php /cgi-bin/php
> >
> > </quote>
> >
> > As I could not find an ordinary php-port (not sure now, it's month ago), 
>I
> > removed one "--with-apxs" entry within the Makefile from www/mod_php4 
>(!)
> > and php ran as cgi!
> >
> > Half a year later, I updated the ports-tree and I was happy to see a
> > www/php4-cgi port and immediately checked this out on a test system. 
>This
> > time, I did not edit the php4-cgi makefile of course, as I expected to
> > have php4 as cgi compiled. I again copied the php-binary, as said above 
>to
> > cgi-bin and surprisingly saw only "500 - internal server error" and I
> > found a "Premeture end of script headers: /usr/local/www/cgi-bin/php in
> > httpd-error.log.
> >
> > One thing you have to know is, that our scripts are in
> > /usr/local/www/data/"our-php-application". This worked on this 4.7/this
> > edited mod_php4-system very well.
> >
> > I posted to the Germany user list, checked google. I found a few hints,
> > but nothing really helped.
> > e.g.:
> > http://www.php.net/manual/en/security.cgi-bin.php
> > http://httpd.apache.org/docs/howto/cgi.html
> >
> > My question basically is:
> > How do I setup this php/cgi environment?
> >
> > One way, I was told and can be found on php.net is to add a
> > "#!/usr/local/lib/php" on top of every php-Skript and all scripts need
> > chmod a+x and need to be in /cgi-bin. This would work. But it is a 
>little
> > uncomfortable way and the main thing is that it would not work with our
> > "php-application", which is a set of css, html, php, pictures, so
> > pictures, css, etc would be parsed, too!
> >
> >
> > There are other solutions, one with an AddHandler directive in 
>httpd.conf,
> > but I don't get that running.
> >
> > As it worked half a year ago and as there is a similar way in IIS, to 
>map
> > an extension (.php) to an application (c:\php\bin\php.exe), I suppose 
>that
> > there is a similar way, but I am just to blind to find the solution!
> >
> > My second question is:
> > Why did it work with those instructions from umn-mapserver wiki-pages 
>and
> > why does the same thing not work now?
> >
> >
> > One way to find out, what's wrong, was to cp /bin/cat to
> > /usr/local/www/cgi-bin/php. But the error is the same.
> >
> >
> > I would be very grateful for hints/help!
> >
> > Thanks in advance!
> >
> > Best Regards,
> > Benjamin
> >
> > _________________________________________________________________
> > Get MSN 8 and help protect your children with advanced parental 
>controls.
> > http://join.msn.com/?page=features/parental
> >
> > _______________________________________________
> > freebsd-questions at freebsd.org mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> > To unsubscribe, send any mail to
> > "freebsd-questions-unsubscribe at freebsd.org"
> >
> >
>
>Hi all,
>
>sorry for that late response! It took, quite a while to find the solution.
>
>Yes, it is the UMN Mapserver and yes it the php-mapscript part which needs
>php to be compiled as a cgi. BTW, I don't get the mapscript-part from
>mapserver 4.0 compiled. They changed the php-mapscript Makefile a little,
>so that older workarounds don't help anymore. Right, that's for another
>list. Sorry :-).
>
>I found out, how get php as cgi running on FreeBSD using ports/www/php-cgi.
>
>
>To start with: The following lines are required in apache httpd.conf. I
>never had something else! Lucas mail with the Windows example showed, that
>these entries always were correct and I was able to get that running on a
>debian machine:
>
>.
>.
>.
>ScriptAlias /cgi-bin/ /usr/local/www/cgi-bin/
><Directory /usr/local/www/cgi-bin>
>     AllowOverride None
>     Options ExecCGI
>     Order allow,deny
>     Allow from all
></Directory>
>.
>.
>.
>AddType  application/x-httpd-php .php
>Action application/x-httpd-php /cgi-bin/php
>
>
>I downloaded the original source code and compiled it, having configured
>it just with ./configure. I copied the php-binary to
>/usr/local/www/cgi-bin and I couldn't believe it, php was running as a
>cgi!!
>So it was just a thing to find out which option causes this error. It is
>the "--enable-discard-path" which is used as a default by
>ports/www/php4-cgi.
>Having compiled php with this option on debian causes the same symptom!
>
>
>But I want to use ports. I edited the ports/lang/php4 Makefile like this:
>
>
>CONFIGURE_ARGS= --enable-versioning \
>                 --enable-force-cgi-redirect \ # recommended for cgi
>                 --with-regex=system \         # needed by mapserver*
>                 --enable-memory-limit \
>                 --with-layout=GNU \
>                 --with-zlib-dir=/usr \
>                 --disable-all
>
>
>*Actually the following part would do the same, but I couldn't find out
>how to tell 'make' WITH_REGEX_TYPE=system. So I changed the Makefile a
>little.
>There is another knob 'WITH_LZW' but it's the same problem. I don't know
>how to tell 'make' this. Does somebody know?
>
>#.if !defined(WITH_REGEX_TYPE) || ${WITH_REGEX_TYPE} == "php"
>#CONFIGURE_ARGS+=--with-regex=php
>#.else
>#.if ${WITH_REGEX_TYPE} == "system"
>#CONFIGURE_ARGS+=--with-regex=system
>#.else
>#.if ${WITH_REGEX_TYPE} == "apache"
>#CONFIGURE_ARGS+=--with-regex=apache
>#.endif
>#.endif
>#.endif
>
>
>this the major part to get php4-cgi running on FreeBSD:
>
>
>#.if defined(WITHOUT_APACHE)
>#CONFIGURE_ARGS+=--enable-discard-path
>#PLIST_SUB+=    APACHE="@comment "
>#.else
>#PLIST_SUB+=    APACHE=""
>#.endif
>
>
>Finally I of course would like know what it's all about 'discard-path' why
>does the maintainer Alex Dupres use this as a default and why conflicts my
>httpd-configuration with 'discard-path'!?
>
>Thanks,
>Benjamin

_________________________________________________________________
Get MSN 8 and enjoy automatic e-mail virus protection.    
http://join.msn.com/?page=features/virus



More information about the freebsd-questions mailing list