### Compile and install PostgreSQL with make Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/verboselinuxinstall.txt Compiles and installs PostgreSQL. Must be run as root or with superuser privileges; the example user has superuser privileges. ```shell [anthony3@aragog postgresql-8.1.2]$ make make -C doc all make[1]: Entering directory '/usr/local/postgresql-8.1.2/doc' gzip -d -c man.tar.gz | /bin/tar xf - . . . All of PostgreSQL successfully made. Ready to install. [anthony3@aragog postgresql-8.1.2]$ make install make -C doc install make[1]: Entering directory '/usr/local/postgresql-8.1.2/doc' mkdir -p -- /usr/local/pgsql/doc/html . . . PostgreSQL installation complete. [anthony3@aragog postgresql-8.1.2]$ ``` -------------------------------- ### Command prompt for PHP installation Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/verboselinuxinstall.txt Shows the command prompt used in the PHP installation examples. The user 'anthony3' has superuser privileges. ```shell [anthony3@aragog php-5.1.2]$ ``` -------------------------------- ### PostgreSQL installation instructions (from other doc) Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/mapserver_openbsd_3.7_jan_2005.txt Commands to build and initialize a PostgreSQL database, as referenced from another document. Includes creating a user, initializing the database, starting the server, and creating a test database. ```shell cd postgresql-7.3.4 ./configure gmake su gmake install adduser postgres mkdir /$your database location chown postgres /$your database location su - postgres /usr/local/pgsql/bin/initdb -D /$your database location /usr/local/pgsql/bin/postmaster -D /$your database location >logfile 2>&1 & logout from superuser login as postgres /usr/local/pgsql/bin/createdb test /usr/local/pgsql/bin/psql test ``` -------------------------------- ### Install Python on Linux Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/documentation.txt Example command to install Python 3.9 on Debian-based distributions. ```bash sudo apt-get install python3.9 ``` -------------------------------- ### phpinfo() output example Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/verboselinuxinstall.txt Expected output when accessing http://localhost/ after installing PHP. Shows the phpinfo() page with PHP version and configuration details. ```text PHP Logo PHP Version 5.1.2 System Linux aragog 2.6.14-1.1656_FC4smp #1 SMP Thu Jan 5 22:24:06 EST 2006 i686 Build Date Jan 23 2006 21:27:57 Configure Command './configure' '--prefix=/usr/local/apache2/php' '--with-apxs2=/usr/local/apache2/bin/apxs' '--disable-cgi' '--with-config-file-path=/usr/local/apache2/php' '--with-openssl' '--with-kerberos' '--with-zlib' '--with-bz2' . . . If you did not receive a copy of the PHP license, or have any questions about PHP licensing, please contact license@php.net. ``` -------------------------------- ### Compile and install Apache with make and make install Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/verboselinuxinstall.txt Compile and install Apache. You must be root or have superuser privileges; the user anthony3 has them in this documentation. ```bash [anthony3@aragog httpd-2.2.0]$ make Making all in srclib make[1]: Entering directory '/usr/local/httpd-2.2.0/srclib' Making all in apr . . . make[1]: Leaving directory '/usr/local/httpd-2.2.0' [anthony3@aragog httpd-2.2.0]$ make install Making install in srclib make[1]: Entering directory '/usr/local/httpd-2.2.0/srclib' Making install in apr . . . make[1]: Leaving directory '/usr/local/httpd-2.2.0' [anthony3@aragog httpd-2.2.0]$ ``` -------------------------------- ### Start Apache with apachectl start Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/verboselinuxinstall.txt Start the Apache server using apachectl. After starting, test by visiting http://localhost/ in a web browser; you should see the 'Test Page for Apache Installaion'. ```bash [anthony3@aragog httpd-2.2.0]$ /usr/local/apache2/bin/apachectl start [anthony3@aragog httpd-2.2.0]$ ``` -------------------------------- ### Compile and install PHP with make and make install Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/verboselinuxinstall.txt Commands to compile and install PHP. Run 'make' and then 'make install' as root or with superuser privileges. Warnings about tempnam and tmpnam can be ignored. ```shell [anthony3@aragog php-5.1.2]$ make /bin/sh /usr/local/php-5.1.2/libtool --silent --preserve-dup-deps --mode=compile gcc -Iext/libxml/ -I/usr/local/php-5.1.2/ext/libxml/ -DPHP_ATOM_INC -I/usr/local/php-5.1.2/include -I/usr/local/php-5.1.2/main -I/usr/local/php-5.1.2 -I/usr/include/libxml2 -I/usr/kerberos/include -I/usr/local/ php-5.1.2/ext/date/lib -I/usr/include/mysql -I/usr/local/pgsql/include -I/usr/local/php-5.1.2/TSRM -I/usr/local/php-5.1.2/Zend -I/usr/include -g -O2 . . . (It is safe to ignore warnings about tempnam and tmpnam). [anthony3@aragog php-5.1.2]$ make install Installing PHP SAPI module: apache2handler /usr/local/apache2/build/instdso.sh SH_LIBTOOL='/usr/local/apache2/build/libtool' libphp5.la /usr/local/apache2/modules /usr/local/apache2/build/libtools --mode=install cp libphp5.la /usr/local/apache2/modules/ . . . Installing PDO headers: /usr/local/apache2/php/include/php/ext/pdo/ [anthony3@aragog php-5.1.2]$ ``` -------------------------------- ### msIO_installStdinFromBuffer() Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/rfc/ms-rfc-16.txt Installs a handler to get stdin from a buffer and clears the buffer. ```c msIO_installStdinFromBuffer(); ``` -------------------------------- ### Install Transifex client Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/documentation.txt Install the Transifex client package. ```bash sudo apt-get install transifex-client ``` -------------------------------- ### MapServer version output example Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/introduction.txt Example output from running the MapServer CGI program to verify the installation. The exact output depends on your configuration and compiled features. ```text MapServer version 7.0.1 (MS4W 3.1.4) OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE ``` -------------------------------- ### Getting MapServer Running Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/introduction.txt Instructions to verify MapServer installation by running the mapserv executable with -v parameter. ```APIDOC ## Getting MapServer Running ### Description Test if MapServer is working by running the `mapserv` executable with the `-v` parameter. ### Command ```bash ./mapserv -v ``` For MS4W users installed via `-setup.exe`, use the `MS4W-Shell` shortcut and run `mapserv -v`. For MS4W users who did not use `-setup.exe`, open a Command Prompt, cd to the installation folder, run `setenv.bat`, then test `mapserv -v`. ``` -------------------------------- ### Build and install AGG library Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/mapserverubuntu.txt Builds and installs AGG with an .so format library, using /usr as the installation prefix. ```bash cd . autogen.sh ./configure --prefix=/usr make sudo make install ``` -------------------------------- ### Install pip on Linux Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/documentation.txt Download get-pip.py and run it to install pip. ```bash curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python get-pip.py ``` -------------------------------- ### Install multiple MapServer instances with different configure options Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/announce/6-2.txt Shows how to build and install two MapServer instances with different configurations (e.g., with and without GD) using separate --prefix directories. Requires running 'make install' as a privileged user and symlinking the installed mapserv binary to the CGI directory. ```bash $ ./configure --without-gd --prefix=/opt/ms-62-nogd $ make && sudo make install $ ln -s /opt/ms-62-nogd/bin/mapserv /usr/lib/cgi-bin/mapserv $ make clean $ ./configure --with-gd --prefix=/opt/ms-62-gd $ make && sudo make install $ ln -s /opt/ms-62-gd/bin/mapserv /usr/lib/cgi-bin/mapserv-62-gd ``` -------------------------------- ### Configure, build, and install from source Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/suse-linux.txt Run the configure script to generate a system-specific makefile, then build and install the software. The configure command accepts optional options; use --help to list them. After installation, run ldconfig to update the linker cache. ```bash ./configure [optional: --with-option / usually –h or --help prints out all available options] ``` ```bash # ./configure # make # make install # ldconfig ``` -------------------------------- ### Install pre-commit hooks Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/dev_practices.txt Commands to install pre-commit and set up the hooks for the repository. ```bash python3 -m pip install pre-commit pre-commit install ``` -------------------------------- ### Compile and install MapServer Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/installation/v8.txt Compiles and installs MapServer from the build directory after configuration. ```bash make install ``` -------------------------------- ### Install MapServer libraries Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/installation/unix.txt Install MapServer libraries and verify the mapserv binary exists. ```bash # make install ``` ```bash $ ls -al mapserv -rwxr-xr-x 1 user user 13745 mars 11 17:45 mapserv ``` -------------------------------- ### Build and install MapServer from source Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/RedHat9andMapServer40.txt Build and install MapServer from the distribution source. The configure file is not executable, so chmod is required first. After installation, run ldconfig and change to the parent directory. ```bash chmod +x ./configure ./configure make sudo make install sudo /sbin/ldconfig cd ../.. ``` -------------------------------- ### Install TinyOWS from GIT trunk Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/tinyows/serverinstallation.txt Build and install TinyOWS from the current trunk in GIT. Requires autoconf and git. After installation, copy the tinyows binary to your cgi-bin directory. ```bash $ git clone https://github.com/MapServer/tinyows.git $ cd tinyows $ autoconf $ ./configure $ make $ sudo make install $ sudo make install-demo ``` -------------------------------- ### Quick start: createMap example in cfscript Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/coldfusion.txt Example of using the mapscript CFC in ColdFusion cfscript. Requires the CFC to be mapped, mapscript.jar in classpath, and the shared library available. The init method sets paths for saving, map files, and shapefiles; createMap generates a map with specified legend and dimensions. ```ColdFusion msapi = createObject("component","mapscript"); msapi.init(savePath="/your/directory/to/save/to/", mapPath="/where/the/mapfiles/are/", mapFile="mapfilename.map", shapePath="/the/location/to/the/shapefiles/"); mapinfo = msapi.createMap(legend="false", width="450", height="450"); ``` -------------------------------- ### Install pip on Windows using get-pip.py Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/documentation.txt Run this after downloading get-pip.py locally to install pip. ```bash python get-pip.py ``` -------------------------------- ### Compile and Install GDAL Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/mapserver_compilation_on_suse_10.txt Extract, configure, compile, and install GDAL. ```bash $ tar -xzvf gdal-1.3.1.tar.gz $ cd gdal-1.3.1/ $ ./configure --prefix=/usr/local $ make $ su -c "make install" ``` -------------------------------- ### gml_groups example Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/ogc/wfs_server.txt Example of setting up a group named 'display' with attributes 'Name_e' and 'Name_f'. ```text "gml_include_items" "all" "gml_groups" "display" "gml_display_group" "Name_e,Name_f" ``` -------------------------------- ### Install base packages with apt-get Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/debian-install.txt Install the first set of required Debian packages for building MapServer. This is the first of three commands needed to install all required packages. ```shell # apt-get install g++ apache bison bzip2 unzip proj ``` -------------------------------- ### List of required libraries Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/freebsd62mapserver410.txt List of libraries to install using the ports system, each with 'make install clean'. ```text jpeg png tiff gd proj geos ``` -------------------------------- ### PostGIS build and install procedure Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/mapserver_openbsd_3.7_jan_2005.txt Commands to build and install PostGIS from source, including loading the PostGIS SQL files into a database. The note mentions that forgetting to run 'make install' first can cause problems. ```shell cd contrib gunzip postgis-0.7.1.tar.gz tar xvf postgis-0.7.1.tar cd postgis-0.7.1 make make install (forgot to do the make install first time - leading to mayhem) (i switched to postgres user here) createlang plpgsql test psql -d test -f postgis.sql psql -d test -f spatial_ref_sys.sql ``` -------------------------------- ### Install Apache, PHP, and FastCGI packages Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/installation/unix.txt Install Apache and related packages on Debian/Ubuntu to run MapServer as CGI. ```bash $ apt-get install -y apache2 apache2-mpm-worker libapache2-mod-fastcgi $ a2enmod actions fastcgi alias $ apt-get install libapache2-mod-php5 php5-common php5-cli php5-fpm php5 ``` -------------------------------- ### Install MapServer packages with apt-get Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/Debian_Lenny_install_guide.txt Install MapServer and its components on Debian Lenny. Run as root. This installs the CGI, utilities, documentation, and language bindings. ```bash apt-get install cgi-mapserver mapserver-bin mapserver-doc php-mapscript python-mapscript ``` -------------------------------- ### Install TinyOWS from stable source release Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/tinyows/serverinstallation.txt Download, configure, and install TinyOWS from a stable source release. Requires autoconf, make, and sudo privileges. After installation, copy the tinyows binary to your cgi-bin directory. ```bash $ wget https://download.osgeo.org/mapserver/tinyows-1.2.0.tar.gz $ tar xzvf tinyows-1.2.0.tar.gz $ cd tinyows-1.2.0 $ autoconf $ ./configure $ make $ sudo make install $ sudo make install-demo ``` -------------------------------- ### Compile and Install PROJ.4 Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/mapserver_compilation_on_suse_10.txt Extract, configure, compile, and install PROJ.4. ```bash $ tar -xzvf proj-4.4.9.tar.gz $ cd proj-4.4.9 $ ./configure --prefix=/usr/local $ make $ su -c "make install" ``` -------------------------------- ### Configure Z-top cache in mapcache.xml Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/rfc/ms-rfc-130.txt Example configuration for a Z-top cache starting at zoom level 8, including the composite cache setup to address all zoom levels. ```xml 8 /path/to/z{top}-{top_x}-{top_y}.sqlite3 /path/to/z0-0-0.sqlite3 z1-7 z8 ``` -------------------------------- ### List configure options with ./configure --help Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/mapscript_java.txt Run this command to list all available configure options, including the --disable-X flags for disabling unwanted features. ```bash ./configure --help ``` -------------------------------- ### Install MapServer dependencies on RedHat 9 Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/RedHat9andMapServer40.txt Commands to download, build, and install PDFlib-Lite, ming, curl, gd-2, proj, and Xerces libraries on RedHat 9. Each block is a separate installation step; run them in order. Requires sudo privileges and network access. ```bash wget http://www.pdflib.com/products/pdflib/download/PDFlib-Lite-5.0.2-Unix-src.tar.gz tar xzf PDFlib-Lite-5.0.2-Unix-src.tar.gz cd PDFlib-Lite-5.0.2-Unix-src make clean ./configure make sudo make install cd .. ``` ```bash wget http://www.opaque.net/ming/ming-0.2a.tgz tar xzf ming-0.2a.tgz cd ming-0.2a make clean make make static sudo make install ``` ```bash wget http://curl.haxx.se/download/curl-7.10.7.tar.gz tar xzf curl-7.10.7.tar.gz cd curl-7.10.7 make clean ./configure make sudo make install ``` ```bash sudo /sbin/ldconfig ``` ```bash rm -f /usr/lib/libgd.* # to remove any potentially conflicts wget http://www.boutell.com/gd/http/gd-2.0.15.tar.gz tar xzf gd-2.0.15.tar.gz cd gd-2.0.15 make clean ./configure make sudo make install cd .. ``` ```bash wget --passive-ftp ftp://ftp.remotesensing.org/pub/proj/proj-4.4.7.tar.gz wget --passive-ftp ftp://ftp.remotesensing.org/pub/proj/proj-nad27-1.1.tar.gz tar xzf proj-4.4.7.tar.gz cd proj-4.4.7/nad tar xzf ../../proj-nad27-1.1.tar.gz cd .. ./configure make sudo make install ``` ```bash wget http://www.maptools.org/dl/proj4-epsg-with-42xxx-and-esri.zip unzip proj4-epsg-with-42xxx-and-esri.zip sudo mv epsg /usr/local/share/proj/ ``` ```bash wget http://xml.apache.org/dist/xerces-c/stable/archives/Xerces-C_1_6_0/xerces-c-src1_6_0.tar.gz tar xzf xerces-c-src1_6_0.tar.gz cd xerces-c-src1_6_0 #set SERCESROOT to the xerces source directory export XERCESCROOT=`pwd` cd src ``` -------------------------------- ### Build and install nginx Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/mapcache/install.txt Builds and installs nginx after configuration. This compiles the MapCache module into nginx. ```bash $ make $ sudo make install ``` -------------------------------- ### Create and open web.config Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/installation/iis.txt Creates an empty web.config file and opens it in Notepad as administrator. ```bat copy NUL C:\Inetpub\wwwroot\mapserver\web.config notepad C:\Inetpub\wwwroot\mapserver\web.config ``` -------------------------------- ### Install protobuf-c dependencies for MVT support Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/output/tile_mode.txt Ubuntu command to install the protobuf-c compiler and development library required for MapServer MVT support. After installation, compile MapServer with the -DWITH_PROTOBUFC=ON switch. ```bash sudo apt install protobuf-c-compiler libprotobuf-c-dev ``` -------------------------------- ### Get Summary of MySQL Spatial Layer with ogrinfo Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/input/vector/mysql.txt Use ogrinfo with the -summary flag to get a summary of a spatial layer. The example shows the output for the 'province' layer. ```text > ogrinfo MYSQL:test,user=root,password=mysql,port=3306 province -summary ``` ```text INFO: Open of `MYSQL:test,user=root,password=mysql,port=3306' using driver `MySQL' successful. Layer name: province Geometry: Polygon Feature Count: 48 Extent: (-13702.315770, 3973784.599548) - (1127752.921471, 4859616.714055) Layer SRS WKT: PROJCS["ED50_UTM_zone_30N", ... FID Column = OGR_FID Geometry Column = SHAPE id: Real (2.0) ... ``` -------------------------------- ### Compile and Install GEOS Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/mapserver_compilation_on_suse_10.txt Compile the source code and install it with root privileges. ```bash $ make $ su -c "make install" ``` -------------------------------- ### Python MapScript example with stdout buffer Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/rfc/ms-rfc-16.txt A complete Python MapScript example that loads parameters from CGI, installs the stdout buffer, dispatches the request, and prints the buffered output with a text/plain content type. ```python #!/usr/bin/env python import sys import mapscript req = mapscript.OWSRequest() req.loadParams() mapscript.msIO_installStdoutToBuffer() map.OWSDispatch( req ) print 'Content-type: text/plain' print print mapscript.msIO_getStdoutBufferString() ``` -------------------------------- ### Example date output Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/mapfile/template.txt Example output of the [date] substitution in the default format, showing the date and time with timezone offset. ```text 01/Dec/2010:17:34:58 -0800 ``` -------------------------------- ### Build and install geos from source Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/mapserver_openbsd_3.7_jan_2005.txt Commands to download, configure, build, and install geos 2.1.1 from its tarball. This is a prerequisite for postgis. ```shell http://geos.refractions.net/geos-2.1.1.tar.bz2 ./configure make make install ``` -------------------------------- ### Check pip installation on Windows Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/documentation.txt Verify pip is installed by running pip help. If not found, download get-pip.py. ```bash pip help ``` -------------------------------- ### Resulting Features: Get all queried features Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/mapscript/querying.txt Extends the previous example to open the layer, iterate over results, get each shape, and print an attribute value. The layer must be opened before reading shapes and closed when done. ```python layer.template = "FAKE" layer.queryByAttributes(test_map, "FID", '"1"', mapscript.MS_MULTIPLE) results = layer.getResults() if results: # open layer in preparation of reading shapes layer.open() for i in range(results.numresults): result = results.getResult(i) shape = layer.getShape(result) # get the value of the attribute at index 1 print(shape.getValue(1)) # close when done layer.close() ``` -------------------------------- ### Enable Apache site and restart Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/basemaps/install.txt Commands to copy the Apache configuration, enable the site, and gracefully restart Apache. ```bash $ cp osm.conf /etc/apache/site-available/conf/ $ sudo a2ensite osm $ sudo /etc/init.d/apache2 graceful ``` -------------------------------- ### Regular expression comparison Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/introduction.txt Example of a regular expression CLASS expression. Matches values starting with 9 or 10. ```mapfile EXPRESSION /^9|^10/ ``` -------------------------------- ### Install libfcgi-dev on Ubuntu Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/installation/unix.txt Install the FastCGI development package on Ubuntu using apt-get. Required for FastCGI support in MapServer. ```bash $ apt-get -y install libfcgi-dev ``` -------------------------------- ### Start PostgreSQL and test with createdb and psql Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/verboselinuxinstall.txt Starts the PostgreSQL server with pg_ctl, creates a test database, connects with psql, and exits. The output shows the expected messages from each command. ```shell [postgres@aragog postgresql-8.1.2]$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data/ -l /usr/local/pgsql/data/logfile start postmaster starting [postgres@aragog postgresql-8.1.2]$ /usr/local/pgsql/bin/createdb test CREATE DATABASE [postgres@aragog postgresql-8.1.2]$ /usr/local/pgsql/bin/psql test Welcome to psql 8.1.2, the PostgreSQL interactive terminal. Type: \copyright for distribution terms . . . test=# \q [postgres@aragog postgresql-8.1.2]$ exit [anthony3@aragog postgresql-8.1.2]$ ``` -------------------------------- ### wms_allowed_gdal_drivers metadata example Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/ogc/wms_client.txt Sets the allowed GDAL drivers for opening the image returned by the remote server. The default is "PNG,JPEG" (starting with version 8.2.0); this example adds WEBP. The separator is a comma. ```mapfile METADATA "wms_allowed_gdal_drivers" "PNG,JPEG,WEBP" # to allow WEBP as well END ``` -------------------------------- ### PHP configure error: libpng not found Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/verboselinuxinstall.txt Example error message when configuring PHP. The solution is to install the matching -devel package, such as libpng-devel-1.2.8-2.i386.rpm. ```text If configure fails try --with-jpeg-dir= configure: error: libpng.(a|so) not found. ``` -------------------------------- ### Configure Apache with --enable-so and --with-mpm=prefork Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/verboselinuxinstall.txt Configure Apache with the options shown. The --enable-so and --with-mpm=prefork options are the only required ones; the rest are optional. Use ./configure --help for more options. ```bash [anthony3@aragog local]$ cd httpd-2.2.0/ [anthony3@aragog httpd-2.2.0]$ ./configure \ > --prefix=/usr/local/apache2 \ > --enable-deflate \ > --enable-info \ > --enable-mime-magic \ > --enable-rewrite \ > --enable-so \ > --enable-speling \ > --enable-ssl \ > --enable-unique_id \ > --enable-usertrack \ > --with-mpm=prefork checking for chosen layout... Apache checking for working mkdir -p... yes checking build system type... i686-pc-linux-gnu . . . config.status: executing default commands [anthony3@aragog httpd-2.2.0]$ ``` -------------------------------- ### GEOMETRYTRANSFORM start([geom]) usage Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/rfc/ms-rfc-48.txt Treats the underlying geometry as a point rendered on the first vertex of the current feature. This is the initial example usage of the GEOMETRYTRANSFORM keyword. ```mapfile GEOMETRYTRANSFORM "start([geom])" ``` -------------------------------- ### Set and get a label color binding Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/mapscript/php/index-5.6.txt Sets a label color binding and then retrieves it. The getBinding method returns the bound field name, which is FIELD_NAME_COLOR in this example. ```php $oLabel->setbinding(MS_LABEL_BINDING_COLOR, "FIELD_NAME_COLOR"); echo $oLabel->getbinding(MS_LABEL_BINDING_COLOR); // FIELD_NAME_COLOR ``` -------------------------------- ### Configure automatic startup of Apache Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/verboselinuxinstall.txt Copy apachectl to /etc/init.d/ and then edit /etc/init.d/apachectl to add the chkconfig, description, processname, and pidfile lines shown. These lines enable automatic startup of Apache. ```bash [anthony3@aragog httpd-2.2.0]$ cp /usr/local/apache2/bin/apachectl /etc/init.d/. [anthony3@aragog httpd-2.2.0]$ ``` ```bash #!/bin/sh # # chkconfig: - 85 15 # description: Apache is a Web server used to serve HTML and CGI. # processname: httpd # pidfile: /usr/local/apache2/logs/httpd.pid # ``` -------------------------------- ### Debian /etc/apt/sources.list examples Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/debian-install.txt Example entries for /etc/apt/sources.list showing Debian repositories for stable, sarge, unstable, and security updates. Use code-names like woody, sarge, or sid instead of release names for stability. ```text deb http://ftp.tu-clausthal.de/pub/linux/debian/ stable main non-free contrib deb-src http://ftp.tu-clausthal.de/pub/linux/debian/ stable main non-free contrib ``` ```text deb http://ftp.de.debian.org/debian sarge main contrib non-free deb-src http://ftp.de.debian.org/debian sarge main contrib non-free ``` ```text deb http://http.us.debian.org/debian unstable main contrib non-free deb-src http://http.us.debian.org/debian unstable main contrib non-free ``` ```text deb http://security.debian.org/ stable/updates main contrib non-free ``` -------------------------------- ### POINTS example: single feature Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/mapfile/feature.txt Defines a set of xy pairs terminated with END. For POLYGON/POLYLINE layers, points must start and end with the same point to close the feature. ```mapfile POINTS 1 1 50 50 1 50 1 1 END ``` -------------------------------- ### PostGIS layer with plaintext password Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/utilities/msencrypt.txt A PostGIS layer example with an unencrypted password in the CONNECTION string. This is the starting point for the encryption workflow; requires MapServer 5.0.3 or 5.2 or later. ```mapfile LAYER NAME "provinces" TYPE POLYGON CONNECTIONTYPE POSTGIS CONNECTION "host=127.0.0.1 dbname=gmap user=postgres password=iluvyou18 port=5432" DATA "the_geom FROM province using SRID=3978" STATUS DEFAULT CLASS NAME "Countries" STYLE COLOR 255 0 0 END END END ``` -------------------------------- ### Create tile index for all tiles (Unix and Windows) Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/utilities/tile4ms.txt Short example creating tileindex.shp for all tiles under /path/to/data. On Unix, change to the data directory, use find to list .shp files into metafile.txt, then run tile4ms. On Windows, use dir /b /s *.shp to create the metafile, then run tile4ms. ```shell cd /path/to/data find . -name "/*.shp" -print > metafile.txt tile4ms metafile.txt tileindex ``` ```shell dir /b /s *.shp > metafile.txt tile4ms metafile.txt tileindex ``` -------------------------------- ### SYMBOL parameter with URL Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/mapfile/style.txt Example of using the SYMBOL parameter with a URL to specify a pixmap symbol file. The URL must start with 'http'. This feature was added in version 6.0. ```mapfile SYMBOL "http://myserver.org/path/to/file.png" ``` -------------------------------- ### ogrinfo Command to Get Extent Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/tutorial/example1-1.txt Command using the GDAL/OGR utility ogrinfo to retrieve the extent of a Shapefile dataset. Run with 'states_ugl.shp' to obtain the bounding box for the example data. ```text ogrinfo -al -so states_ugl.shp ``` -------------------------------- ### DescribeSensor HTTP GET Request Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/ogc/sos_server.txt Example request to the SOS server using the DescribeSensor operation. The URL includes parameters for map, request, procedure, service, version, and outputFormat. ```http http://127.0.0.1/cgi-bin/mapserv.exe?map=D:/ms4w/apps/sos/sos_test.map& Request=DescribeSensor&procedure=urn:ogc:def:procedure:NS01EE0014& service=SOS&version=1.0.0&outputFormat=text/xml; subtype="sensorML/1.0.0" ``` -------------------------------- ### Build HTML documentation on Windows Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/documentation.txt Generate HTML output in the _build/html sub-directory. ```bash make html ``` -------------------------------- ### PHP MapScript access to CLUSTER object Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/mapfile/cluster.txt Shows how to access the CLUSTER object through PHP MapScript. The example creates a map object, gets a layer by name, and accesses the cluster property. ```php $map = ms_newMapobj("/var/www/vhosts/mysite/httpdocs/test.map"); $layer1=$map->getLayerByName("test1"); $layer1->cluster; ``` -------------------------------- ### WMS GetMap with PropertyIsEqualTo filter Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/rfc/ms-rfc-118.txt Example of a WMS GetMap request with a simple PropertyIsEqualTo filter on a single layer. The FILTER parameter must be URL encoded when sent as a GET request. ```http /cgi-bin/mapserv?map=... &SERVICE=WMS &REQUEST=GetMap &LAYERS=popplace &FILTER=NAMEDigby &... ``` -------------------------------- ### Set up VC++ environment and compile MapServer Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/installation/win32.txt Commands to set up the Visual C++ environment by running vcvars32.bat and then compile MapServer with nmake. The output shows the expected environment setup message. ```batch C:\Users> cd \projects\MapServer C:\Projects\MapServer&> C:\Program Files\Microsoft Visual Studio\VC98\Bin\vcvars32.bat" C:\Projects\MapServer> Setting environment for using Microsoft Visual C++ tool. C:\Projects\MapServer> ``` -------------------------------- ### HTML template fragment with [lrn] and [PIN] Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/errors.txt Example HTML template fragment used by the LAYER's TEMPLATE. [lrn] is a special keyword for the line number (starting at 1), and [PIN] is a feature attribute name. ```html [lrn] [PIN] ``` -------------------------------- ### Initialize PostgreSQL database with initdb Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/verboselinuxinstall.txt Creates a postgres user, prepares the data directory, and initializes the database cluster with initdb. The output includes a note that the data directory must be owned by the postgres user. ```shell [anthony3@aragog postgresql-8.1.2]$ /usr/sbin/adduser postgres [anthony3@aragog postgresql-8.1.2]$ mkdir /usr/local/pgsql/data [anthony3@aragog postgresql-8.1.2]$ chown postgres /usr/local/pgsql/data/ [anthony3@aragog postgresql-8.1.2]$ su - postgres [postgres@aragog postgresql-8.1.2]$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data/ This files belonging to this database system will be owned by user "postgres". This user must also own the server process. . . . or /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start [postgres@aragog postgresql-8.1.2]$ ``` -------------------------------- ### GML 3.2.1 geometry with gml:id attributes Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/rfc/ms-rfc-105.txt Example of a GML 3.2.1 feature with gml:id attributes on geometry elements. The id is generated as "feature_gml_id.serial_number" where serial_number starts at 1 and increments for each subgeometry. ```xml 49.000000 2.000000 50.000000 3.000000 49.000000 2.000000 50.000000 3.000000 ``` -------------------------------- ### TinyOWS configuration file example (config.xml) Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/tinyows/configfile.txt Minimal TinyOWS configuration file defining the service root, PostgreSQL connection, metadata, and two layers (world and france). The root element is mandatory and requires online_resource and schema_dir attributes. ```xml ``` -------------------------------- ### Example of extent structure for future development Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/rfc/ms-rfc-140.txt Shows a JSON structure for an extent property, including a spatial bbox and CRS. This is presented as a guide for future development, potentially using the OGC Features API JSON as a reference. ```json "extent": { "spatial": { "bbox": [ [ -180, -90, 180, 90 ] ], "crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84" } }, ``` -------------------------------- ### Iterate over layer metadata with hashTableObj Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/mapscript/php/index-5.6.txt Iterates over all metadata entries in a layer's hashTableObj using nextkey() and prints each key-value pair. The loop starts with $key = null to get the first key and continues until nextkey() returns NULL. ```php $hashTable = $oLayer->metadata; $key = null; while ($key = $hashTable->nextkey($key)) echo "Key: ".$key." value: ".$hashTable->get($key)."
"; ``` -------------------------------- ### BANDS directive example Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/input/raster.txt Selects specific bands from a raster file. One band is greyscale, three are RGB, four are RGBA. Starting with MapServer 8, a GDAL mask band is automatically used for opacity unless USE_MASK_BAND=NO is set. ```mapfile PROCESSING "BANDS=4,2,1" ``` -------------------------------- ### Initialize mapObj from file Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/mapscript/mapfile.txt Initializes a mapObj from a Mapfile on disk. ```python test_map = mapscript.mapObj('tests/test.map') ``` -------------------------------- ### Example of unresolved dependency error when running Java MapScript Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/mapscript_java.txt This error output shows a typical UnsatisfiedLinkError when libgdal.so.1 is not found. It indicates that the gdal library was not found by the linker, likely because gdal was installed from source. To fix it, add the directory containing libgdal.so.1 to LD_LIBRARY_PATH or -Djava.library.path. ```bash javac -classpath ./:examples/:./mapscript.jar -d examples/ examples/*.java java -classpath ./:examples/:./mapscript.jar -Djava.library.path=. DumpShp ../../tests/point.shp java.lang.UnsatisfiedLinkError: /opt-4.4.2/mapscript/java/libmapscript.so: libgdal.so.1: cannot open shared object file: No such file or directory make: *** [test] Error 255 ``` -------------------------------- ### Download and build PHP 4.3.3 Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/howto/RedHat9andMapServer40.txt Download and build PHP 4.3.3, installing it under /usr/local/php433 to allow multiple PHP versions to coexist. The configure command enables shared libraries, GD, FreeType, PDFlib, MySQL, and other options. After building, copy the CGI binary to /var/www/cgi-bin/php433 and install the configuration file. ```bash wget http://ca.php.net/get/php-4.3.3.tar.gz/from/ca2.php.net/mirror tar xzf php-4.3.3.tar.gz cd php-4.3.3 make clean ./configure --enable-shared --with-regex=system --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib --with-gd=/usr/local --with-freetype-dir=/usr --enable-force-cgi-redirect --enable-dbase --with-pdflib --with-mysql --with-config-file-path=/usr/local/php433/ --prefix=/usr/local/php433 make sudo cp sapi/cgi/php /var/www/cgi-bin/php433 sudo make install sudo cp php.ini-dist /usr/local/php433/php.ini ``` -------------------------------- ### Show summary of a GPX feature type with ogrinfo -summary Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/input/vector/gpx.txt This command displays a summary of a specific feature type (e.g., track_points) including geometry, feature count, extent, SRS, and field definitions. The example uses the -summary flag to get a concise view. ```bash >ogrinfo test.gpx track_points -summary INFO: Open of `test.gpx' using driver `GPX' successful. Layer name: track_points Geometry: Point Feature Count: 661 Extent: (-66.694270, 47.985570) - (-66.675222, 47.990791) Layer SRS WKT: GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.01745329251994328, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4326"]] track_fid: Integer (0.0) track_seg_id: Integer (0.0) track_seg_point_id: Integer (0.0) ele: Real (0.0) time: DateTime (0.0) magvar: Real (0.0) geoidheight: Real (0.0) name: String (0.0) cmt: String (0.0) desc: String (0.0) src: String (0.0) ... ``` -------------------------------- ### Compile C# MapScript for MONO Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/installation/dotnet.txt Compiles mapscript.dll and mapscript_csharp.dll for the MONO framework. Requires installing a recent mono Win32 setup package, setting the CSC variable to mcs.exe, and optionally defining MONO = YES in nmake.opt. Use the same compiler as used for MapServer compilation. ```makefile MONO = YES ``` ```makefile nmake -f makefile.vc ``` -------------------------------- ### Install Vagrant plugins Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/development/tests/vagrant.txt Install the recommended and optional Vagrant plugins: vagrant-vbguest (recommended), vagrant-cachier (optional), and sahara (optional). Run these commands in a terminal. ```bash vagrant plugin install vagrant-vbguest vagrant plugin install vagrant-cachier vagrant plugin install sahara ``` -------------------------------- ### Install V8 library and headers Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/installation/v8.txt Installs the compiled V8 library and headers into /opt/v8. Adjust the library path if using a 32-bit build. ```bash mkdir -p /opt/v8/lib && cp ./out/x64.release/lib.target/libv8.so /opt/v8/lib mkdir /opt/v8/include && cp include/v8* /opt/v8/include ``` -------------------------------- ### Show mapserv install path from make install Source: https://github.com/mapserver/mapserver-documentation/blob/main/en/installation/unix.txt Output from make install showing where mapserv was installed. ```bash -- Installing: /usr/local/bin/mapserv -- Set runtime path of "/usr/local/bin/mapserv" to "/usr/local/lib:/usr/local/pgsql/91/lib" ```