Mapserver on Linux: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
Brian Wilson (talk | contribs)
m Undo revision 7143 by Brian Wilson (talk)
 
(12 intermediate revisions by the same user not shown)
The content of the new revision is missing or corrupted.
Line 1: Line 1:
== How I built MapServer for "Mapping Vietnam" ==
The [http://mapserver.org Mapserver] site is full of useful information. A good way to start is to go to the Documentation page and look for the pages linked there on compilation.


=== Overview ===
To build for hostmonster, I have to use sources since I don't have root access.
At this point, this is a very basic configuration.
GDAL support is required for rasters to work and we need rasters.
Need to add support for MySQL (MyGIS?)
Need to add PNG support
Need to add ZLIB support
=== Download each package, build and install it, in order ===
Libproj
wget http://download.osgeo.org/proj/proj-4.7.0.tar.gz
tar xzf proj-4.7.0.tar.gz
cd proj-4.7.0
./configure --prefix=/home1/seafloor/local
make install
cd ..
GDAL -- See also [[Building GDAL on Linux]]
wget http://download.osgeo.org/gdal/gdal-1.8.0.tar.gz
tar xzf gdal-1.8.0.tar.gz
cd gdal-1.8.0
./configure --prefix=/home1/seafloor/local
make install
cd ..
Mapserver
wget http://download.osgeo.org/mapserver/mapserver-5.6.6.tar.gz
tar xzvf mapserver-5.6.6.tar.gz
cd mapserver-5.6.6
./configure --enable-static=yes --with-gdal=/home1/seafloor/local --with-proj=/home1/seafloor/local
make
cp mapserv ~/public_html/mapserver/cgi-bin/
=== Package prerequisites ===
Originally I built PHP/Mapscript to run under Apache 2.0.54 on a system based on
[http://www.trustix.org/ Trustix Linux] 2.2. I have since revised this document as I have switched to [http://www.ubuntu.com/ Ubuntu].
For performance reasons I want to use PHP as a loadable module so I am
building PHP/Mapscript (as opposed to using it as a CGI).
To build MapServer, you need various '*-dev' packages. Running mapserver only requires installing the base packages.
Packages needed on Ubuntu include the following.
There are probably others. These are the packages I had to add to an already running server system.
build-essential (which installs many compiler tools and libraries)
flex
make (which should already be installed)
apache2-prefork-dev
php4-dev
libxpm-dev libjpeg-dev libpng-dev
libfreetype6-dev
libgd2-xpm-dev
libcurl3-dev is needed for wfs support
proj gdal-bin libgdal1-dev
=== PHP ===
Mapserver and nearly all the software I run now support php version 5,
so I am using the version that comes with Ubuntu.
==== PHP 4 ====
For now I am leaving these notes here which cover building php4 for Mapserver.
I get the source for PHP 4.4.2 from http://www.php.net/
The options I used for the PHP 4.4 configure script on Ubuntu are:
./configure \
        --with-apxs2=`which apxs2` \
        --with-pear \
        --with-gd=/usr --enable-gd-imgstrttf \
        --with-freetype-dir=/usr \
        --with-jpeg-dir=/usr \
        --with-png-dir=/usr \
        --with-xpm-dir=/usr/X11R6 \    ''this is probably not needed''
        --enable-gd-native-ttf \
        --with-zlib \
        --with-gettext \
        --with-xml \
        --with-mysql \
        --with-pgsql
[[Note on configure files]]
Then the usual
  make
  su
  make install
The 'make install' step will modify your httpd.conf file to include the module
but you have to restart apache completely ('apachectl restart' will not work.)
  apachectl stop
  apachectl restart
If you create a file containing <code><?php phpinfo(); ?></code>
and put it in your Web server somewhere, you can test your PHP installation and see what is enabled and see many many other details. Here is my example: http://mapserver.wildsong.biz/phpinfo.php
=== MapServer supporting cast of characters ===
==== Projections ====
Projection transforms are handled by [http://proj.maptools.org/ PROJ]
which is currently at revision 4.4.9
Proj includes a library for performing respective forward and inverse transformation of cartographic data to or from cartesian data with a wide range of selectable projection functions.
Proj4 is provided by the Ubuntu 'proj' package.
==== Raster and vector file support ====
GDAL is for raster files, OGR is for vector files.
'''GDAL''' is the "Geospatial Data Abstraction Library".
GDAL is a translator library for [http://www.gdal.org/formats_list.html raster geospatial data formats].
The Ubuntu package '''gdal-bin''' and the development package '''libgdal1-dev''' are what we need.
The [http://ogr.maptools.org/ OGR] library is a subcomponent of GDAL so you don't need to worry about it if you install GDAL.  The OGR Simple Features Library allows MapServer users to display several types of vector data files in their native formats. For example, MapInfo Mid/Mif and TAB data do not need to be converted to ESRI shapefiles when using OGR support with MapServer.
=== Building MapServer ===
As of this writing, I am building with source version 4.8.3.
The configuration I used for the actual MapServer build looks like this:
./configure \
  --with-httpd=/usr/sbin/apache2 \
  --with-gd            \
  --with-freetype      \
  --with-jpeg          \
  --with-png            \
  --with-tiff          \
  --with-proj          \
  --with-ogr=/usr/bin/gdal-config \
  --with-gdal=/usr/bin/gdal-config \
  --with-wfs \
  --with-php=/usr/include/php4 \
  --with-wmsclient              ''for chameleon''
This builds both the CGI executable 'mapserv' and the PHP/Mapscript module.
There are options to build for other languages including java, perl, python, ruby, and tcl. I might try the python variant soon since I am already using it on the Windows side. If so, I will update this document.
==== Installation of binaries ====
There is no 'make install' option for MapServer. You have to manually copy the files to the correct places. For my Ubuntu system the commands are
cp mapserv /home/httpd/wildsong/cgi-bin/
cp mapscript/php3/php_mapscript.so /usr/lib/php4/20060606/
Locations for binaries are highly system dependent.
The first line will install the CGI executable, which is not really the exciting part. But you can test it immediately without any input; here is my copy: http://neptune.cds1.net/cgi-bin/mapserv
If it works, you will get a page containing this line:
No query information to decode. QUERY_STRING is set, but empty
==== Activating PHP/Mapscript ====
If you just installed php you probably don't have any extensions, so you have add a directory in which to store them. Then you have to put the mapscript module there.
The module will not be loaded unless you add a line in php.ini (mine is in /et /etc/php4) thusly:
extension=php_mapscript.so
You have to restart Apache to get the module to load. You can't really type in a URL to test it but you can still see information about it with [http://mapserver.wildsong.biz/phpinfo.php phpinfo] as mentioned above.
You should see a section in its output similar to this:
MapScript
MapServer version 4.8.3
OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=SVG SUPPORTS=PROJ
SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER
INPUT=EPPL7 INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
PHP MapScript Version ($Revision: 1.242.2.2 $ $Date: 2006/03/16 21:03:01 $)
If you have the right proprietary libraries you can build versions of MapServer that support MrSID and ArcSDE.
== Running Mapserver on Linux ==
Well, I am going to jump back over to the main [[MapServer]] doc here; aside from the obvious differences with paths in the MAP file, it should not really matter whether you are running Apache/PHP on Linux or IIS/PHP on Windows.

Latest revision as of 15:23, 26 April 2012