mapscript, php, fedora core 4 problem
Gavin Simpson
gavin.simpson at UCL.AC.UK
Thu Sep 1 06:54:23 PDT 2005
On Wed, 2005-08-31 at 15:31 +0100, Gavin Simpson wrote:
> Hi,
Dear list,
For the archives, I'll answer this one myself.
Recall that I was trying to use php both as an apache module and as a
cgi, with php_mapscript files being handled via the cgi and all other
php pages via the apache module.
Recent versions of php have a third interface, the cli (command line
interface), which differs from the cgi in one crucial way (with respect
to mapscript and use as a "cgi") - it doesn't send headers, which causes
the "Premature end of script headers" error when used as a cgi.
After googling around I narrowed this problem down to the fact that FC4
was using the php-cli interface. To use the cgi interface, one now has
to call/use php-cgi *not* php.
So the problem was down to not reading the Release Notes that came with
FC4 - which document this issue. So, for the record, here is how I got
mapscript working on a freshly installed FC4 system:
These instructions are based, largely, on the posting of Lindsay C.
Blanton, available via the mapscript wiki:
http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PHPMapScriptFedoraCore but
updated for FC4. I can provide a cleaner html-ified version if this
could be added to the wiki?
Instructions:
1) get the source
2) install some software via yum:
su -c "yum install postgresql-libs proj proj-devel libtiff curl gd gd-
devel freetype freetype-devel php-devel libpng-devel libpng10-devel php-
gd"
3) install needed further support programmes, gdal, ogr etc. (rpms for
FC4 available from http://mappinghacks.com/software.shtml )
4) configure the source:
./configure --with-php=/usr/include/php --with-ogr=/usr/bin/gdal-config
--with-gdal=/usr/bin/gdal-config --with-geos=/usr/bin/geos-config --
with-proj
Your choice of options may differ
5) if all is well, then make
6a) if you just want mapserver cgi then copy mapserv to /var/www/cgi-bin
6b) if you want php_mapscript as well, then
copy ./mapscript/php3/php_mapscript.so
to /usr/lib/php/modules/php_mapscript.so
7) create your php cgi handler in cgi-bin:
su -c "touch /var/www/cgi-bin/php.sh"
su -c "vim /var/www/cgi-bin/php.sh"
edit php.sh so it looks like:
#!/bin/bash
export SCRIPT_FILENAME=$PATH_TRANSLATED
/usr/bin/php-cgi
make the php.sh file executable
8) edit /etc/httpd/conf/httpd.conf and add:
Action phpms-script /cgi-bin/php.sh
AddHandler phpms-script .phpms
in a suitable place. change the phpms bits to reflect your choice of
extension for php_mapscript files.
9) get php to load the php_mapscript module. So:
su -c "touch /etc/php.d/php_mapscript.ini"
su -c "vim /etc/php.d/php_mapscript.ini"
and edit the file so it includes:
; Enable php_mapscript functionality
extension=php_mapscript.so
10) restart apache:
su -c "/sbin/service httpd restart"
11) create a file, say info.php somewhere in your webroot, which
includes the following php snippet:
<?php
phpinfo();
?>
Save the file and view this page in your browser. Look through the
output to find the mapscript entry. If it is not there, then something
is wrong - check the above. If it is there then everything should now be
in place for running .php files through the apache module and .phpms
files via the php-cgi.
Hope this is of use to someone,
Gav
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [T] +44 (0)20 7679 5522
ENSIS Research Fellow [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC [E] gavin.simpsonATNOSPAMucl.ac.uk
UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way [W] http://www.ucl.ac.uk/~ucfagls/
London. WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the MapServer-users
mailing list