Installing Mapserver on Ubuntu


Created on: 8/30/17
Last update: 11/1/19


Installing from Package

Install required packages:

sudo apt-get install apache2 apache2-bin apache2-utils cgi-mapserver mapserver-bin mapserver-doc libmapscript-perl python-mapscript ruby-mapscript

Installing from source

Download MapServer

The latest release of Mapserver can be downloaded at

Take Mapserver 7.0.6 as example:

tar -xzf mapserver-7.0.6.tar.gz


apt-get install cmake


Description: libpng should be on your system by default. Versions back to 1.2.7 should work.

apt-get install libpng-dev


Description: Version 2.x or above is required.

sudo apt install libfreetype6


Description: libjpeg allows MapServer to render images in JPEG format. A sufficient version should be installed by default on your system (probably version 6b from 1998).

apt-get install libjpeg-dev


Description: Zlib should be on your system by default. Though not used directly by mapserver, it’s a mandatory dependency of libpng.


Check installation:

mapserv -v

Enable cgi and fastcgi:

apt-get install libapache2-mod-fcgid
sudo a2enmod cgi fcgid

Configure /etc/apache2/sites-available/000-default.conf and add:

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin/">
    AllowOverride All
    Options +ExecCGI -MultiViews +FollowSymLinks
    AddHandler fcgid-script .fcgi
    Require all granted

Restart apache:

sudo service apache2 restart

Test the link (http://localhost/cgi-bin/mapserv?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities)[http://localhost/cgi-bin/mapserv?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities] and check the retuen message: msCGILoadMap(): Web application error. CGI variable "map" is not set.


Install mapserver on ubuntu 18.04 from official repository

Compiling on Unix

How to install Mapserver on Ubuntu?