Installing MapServer 4.10 on FreeBSD 6.2
FreeBSD 6.2 - Mapserver 4.10.1
With postgres/postgis/php_mapscript. this is assuming installation after a clean install of FreeBSD 6.2, with ports, but no x window system.
The other version numbers are :
SERVER_SOFTWARE : Apache/2.2.4 (FreeBSD) mod_ssl/2.2.4 OpenSSL/0.9.7e-p1 DAV/2 PHP/5.2.1 with Suhosin-Patch
It will really help if you have a copy of the FreeBSD Handbook on the screen of another computer, so you can look for FreeBSD help, and obviously access to the MapServer Website.
:w :q is how to write and quit vi, don't forget to press 'esc' before these commands
Libraries
Use ports to install libararies- First, fix your ports-supfile (look in the Handbook) and choose to get all, or nearly all (see the list of directories below). For the once off cost of getting them all, it can save you a lot of frustration (which I have experienced) because a build fails when the version numbers are wrong.
- Then :
setenv LDFLAGS -lstdc++
(this is important for PostgreSQL, and has to be done before compiling, so do it now. You can check it is set by just typingsetenv
, and making sure it is there.) - then required libraries using the ports system :
cd /usr/ports/graphics/jpeg make install clean
Do this for each of :jpeg png tiff gd proj geos
then for :ftp/ curl textproc/ libxml2 print/ freetype pdflib devel/ doxygen lang/ perl php5-extensions www/ apache22 databases/ postgresql82-server postgis
cvsup ports-supfile(to make sure you are getting the most recent ones)
Mapserver installation
- Once all the libraries are done, it is time to compile MapServer. From where-ever you have downloaded the mapserver package to:
tar -xzf mapserver-4.10.1.tar.gz /usr/local/mapserver-4.10.1 cd /usr/local/mapserver-4.10.1
- Next, create a file with the compile commands - much easier than typing in the whole string at the command prompt
vi config
and put this in, pretty much as it appears below
./configure --with-freetype=/usr/local/bin \ --with-png=/usr/local/lib \ --with-jpeg=/usr/local \ --with-libiconv=/usr/local \ --with-geos=/usr/local/bin/geos-config \ --with-ogr=/usr/local/bin/gdal-config \ --with-gdal=/usr/local/bin/gdal-config \ --with-httpd=/usr/local/sbin/httpd \ --with-wfsclient \ --with-wmsclient \ --enable-runpath \ --enable-debug \ --with-curl-config=/usr/local/bin/curl-config \ --with-proj=/usr/local \ --with-pdf=/usr/local \ --with-tiff=/usr/local \ --with-threads \ --with-wcs \ --with-postgis=/usr/local/bin/pg_config \ --with-php=/usr/local \ --with-xml2-config=/usr/bin/xml2-config # new in 4.10 :w :q - (assuming you are doing all this as root...)
chmod 744 config ./config
- when it has finished (special thanks to Eric 'Lontong' for this fix)
you need to edit Makefile in mapscript/php3 path.
vi mapscript/php3/Makefile
- change variable CFLAGS in the top to something else (e.g. CFLAGS1)
- then change :
CFLAGS112 = $(CFLAGS) $(MS_DEFINE) $(MS_INC) $(PHP_INC) $(PHP_REGEX_INC)
to :
CFLAGS112 = $(MS_DEFINE) $(MS_INC) $(PHP_INC) $(PHP_REGEX_INC)
- and add :
CFLAGS = $(CFLAGS1) $(CFLAGS112)
- finally, scroll down to in
compiler %.o: %.c php_mapscript_util.h php_mapscript.h
$(CC) $(CFLAGS112) -c -o $@ $<
change :
$(CFLAGS112)
to:
$(CFLAGS) :w :q
- then (in /usr/local/mapserver) :
make
(Note that this is not make install clean!)
Install & Test
- when (if?!) it finishes without errors (it will take some time)
cp mapserv /usr/local/www/apache22/cgi-bin/
- and you can test it by typing
mapserv -v
in the directory you have just moved it to. - You also need to move the php extension, and (if you want) add it to your php extensions file list. alternatively, you can call it from your php scripts.
cp mapscript/php3/php_mapscript.so /usr/local/lib/php/20060613/ vi /usr/local/etc/php/extensions.ini
- add the line (use A) :
extension=php_mapscript.so :w :q
- Restart Apache
apachectl graceful
- I find it convenient to have a symlink to the data directory, so :
ln -s /usr/local/www/apache22/data/ htdocs
- put your server.php file in the data (htdocs) directory
vi /htdocs/server.php :w :q
- then point your web browser at your server :
10.0.1.3/server.php
Which tells you that the webserver and php are both working.
- and (very exciting)
10.0.1.3/cgi-bin/mapserv
which should return you the lovely line : No query information to decode. QUERY_STRING is set, but empty.
Congratulations, you're ready to make maps!
This How-to applies to: MapServer 4.10
Re: php_mapscipt
I would suggest that a comment like this might do better in a mailing list, but if you find out please feel free to put the answer here and I will try to incorporate it into the page. (As I said at the top, I'm a beginner, this just worked for me!)
cheers
Ben
php mapscript
what is exactly the php version on you freeBSD ?
thanx
Dany
php version
cheers
Ben
Thanks, Ben
Thanks so much for the great effort for the how-to especially including my name on it :D
Really appreciate it
php_mapscript
I can't load php_mapscript.so module, I got this error "Warning: dl() [function.dl]: MapScript: Unable to initialize module Module compiled with module API=20060613" on FreeBsd 6.3 php5-5.2.3.
Any idea ?
Regards,
Dany