Outdated version of the documentation. Find the latest one here.


QGIS as OGC Data Server

QGIS Server is an open source WMS 1.3, WFS 1.0.0 and WCS 1 1.1.1 implementation that, in addition, implements advanced cartographic features for thematic mapping. The QGIS Server is a FastCGI/CGI (Common Gateway Interface) application written in C++ that works together with a web server (e.g., Apache, Lighttpd). It has Python plugin support allowing for fast and efficient development and deployment of new features. It is funded by the EU projects Orchestra, Sany and the city of Uster in Switzerland.

QGIS Server uses QGIS as back end for the GIS logic and for map rendering. Furthermore, the Qt library is used for graphics and for platform-independent C++ programming. In contrast to other WMS software, the QGIS Server uses cartographic rules as a configuration language, both for the server configuration and for the user-defined cartographic rules.

As QGIS desktop and QGIS Server use the same visualization libraries, the maps that are published on the web look the same as in desktop GIS.

In one of the following manuals, we will provide a sample configuration to set up a QGIS Server. For now, we recommend to read one of the following URLs to get more information:

Sample installation on Debian Squeeze

At this point, we will give a short and simple sample installation how-to for a minimal working configuration using Apache2 on Debian Squeeze. Many other OSs provide packages for QGIS Server, too. If you have to build it all from source, please refer to the URLs above.

Firstly, add the following debian GIS repository by adding the following repository:

$ cat /etc/apt/sources.list.d/debian-gis.list
deb http://qgis.org/debian trusty main
deb-src http://qgis.org/debian trusty main

$ # Add keys
$ sudo gpg --recv-key DD45F6C3
$ sudo gpg --export --armor DD45F6C3 | sudo apt-key add -

$ # Update package list
$ sudo apt-get update && sudo apt-get upgrade

Now, install QGIS-Server:

$ sudo apt-get install qgis-server python-qgis

La instalación de un complemento de ejemplo HelloWorld para probar los servidores. Se puede crear un directorio para mantener los complementos del servidor. Esto se especificará en la configuración del host virtual y transmitirlo al servidor a través de una variable de entorno.

$ sudo mkdir -p /opt/qgis-server/plugins
$ cd /opt/qgis-server/plugins
$ sudo wget https://github.com/elpaso/qgis-helloserver/archive/master.zip
$ # In case unzip was not installed before:
$ sudo apt-get install unzip
$ sudo unzip master.zip
$ sudo mv qgis-helloserver-master HelloServer

Instalar el servidor Apache en un host virtual separado que escuche en el puerto 80. Habilitar el módulo de reescritura de pasar encabezados HTTP BASIC de autenticación:

$ sudo a2enmod rewrite
$ cat /etc/apache2/conf-available/qgis-server-port.conf
Listen 80
$ sudo a2enconf qgis-server-port

Esta es la configuración del host virtual, almacenado en /etc/apache2/sites-available/001-qgis-server.conf :

<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot /var/www/html

  ErrorLog ${APACHE_LOG_DIR}/qgis-server-error.log
  CustomLog ${APACHE_LOG_DIR}/qgis-server-access.log combined

  # Longer timeout for WPS... default = 40
  FcgidIOTimeout 120
  FcgidInitialEnv LC_ALL "en_US.UTF-8"
  FcgidInitialEnv LANG "en_US.UTF-8"
  FcgidInitialEnv QGIS_DEBUG 1
  FcgidInitialEnv QGIS_SERVER_LOG_FILE /tmp/qgis-000.log
  FcgidInitialEnv QGIS_PLUGINPATH "/opt/qgis-server/plugins"

  # ABP: needed for QGIS HelloServer plugin HTTP BASIC auth
  <IfModule mod_fcgid.c>
      RewriteEngine on
      RewriteCond %{HTTP:Authorization} .
      RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  <Directory "/usr/lib/cgi-bin">
      AllowOverride All
      Options +ExecCGI -MultiViews +FollowSymLinks
      # for apache2 > 2.4
      Require all granted
      #Allow from all

Ahora habilitar el host virtual y reiniciar Apache:

$ sudo a2ensite 001-qgis-server
$ sudo service apache2 restart

Probar el servidor con el complemento HelloWorld:

$ wget -q -O - "http://localhost/cgi-bin/qgis_mapserv.fcgi?SERVICE=HELLO"

You can have a look at the default GetCpabilities of the QGIS server at: http://localhost/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities


If you work with a feature that has many nodes then modyfying and adding a new feature will fail. In this case it is possible to insert the following code into the 001-qgis-server.conf file:

<IfModule mod_fcgid.c>
FcgidMaxRequestLen 26214400
FcgidConnectTimeout 60

Creating a WMS/WFS/WCS from a QGIS project

To provide a new QGIS Server WMS, WFS or WCS, we have to create a QGIS project file with some data. Here, we use the ‘Alaska’ shapefile from the QGIS sample dataset. Define the colors and styles of the layers in QGIS and the project CRS, if not already defined.

Figure Server 2:


Definitions for a QGIS Server WMS/WFS/WCS project (KDE)

Then, go to the OWS Server menu of the Project ‣ Project Properties dialog and provide some information about the OWS in the fields under Service Capabilities. This will appear in the GetCapabilities response of the WMS, WFS or WCS. If you don’t check checkbox Service capabilities, QGIS Server will use the information given in the wms_metadata.xml file located in the cgi-bin folder.

WMS capabilities

In the WMS capabilities section, you can define the extent advertised in the WMS GetCapabilities response by entering the minimum and maximum X and Y values in the fields under Advertised extent. Clicking Use Current Canvas Extent sets these values to the extent currently displayed in the QGIS map canvas. By checking checkbox CRS restrictions, you can restrict in which coordinate reference systems (CRS) QGIS Server will offer to render maps. Use the mActionSignPlus button below to select those CRS from the Coordinate Reference System Selector, or click Used to add the CRS used in the QGIS project to the list.

If you have print composers defined in your project, they will be listed in the GetCapabilities response, and they can be used by the GetPrint request to create prints, using one of the print composer layouts as a template. This is a QGIS-specific extension to the WMS 1.3.0 specification. If you want to exclude any print composer from being published by the WMS, check checkbox Exclude composers and click the mActionSignPlus button below. Then, select a print composer from the Select print composer dialog in order to add it to the excluded composers list.

If you want to exclude any layer or layer group from being published by the WMS, check checkbox Exclude Layers and click the mActionSignPlus button below. This opens the Select restricted layers and groups dialog, which allows you to choose the layers and groups that you don’t want to be published. Use the Shift or Ctrl key if you want to select multiple entries at once.

You can receive requested GetFeatureInfo as plain text, XML and GML. Default is XML, text or GML format depends the output format choosen for the GetFeatureInfo request.

If you wish, you can check checkbox Add geometry to feature response. This will include in the GetFeatureInfo response the geometries of the features in a text format. If you want QGIS Server to advertise specific request URLs in the WMS GetCapabilities response, enter the corresponding URL in the Advertised URL field. Furthermore, you can restrict the maximum size of the maps returned by the GetMap request by entering the maximum width and height into the respective fields under Maximums for GetMap request.

If one of your layers uses the Map Tip display (i.e. to show text using expressions) this will be listed inside the GetFeatureInfo output. If the layer uses a Value Map for one of his attributes, also this information will be shown in the GetFeatureInfo output.

QGIS support the following request for WMS service:

  • GetCapabilities
  • GetMap
  • GetFeatureInfo
  • GetLegendGraphic (perfil SLD)

  • DescribeLayer (perfil SLD)

  • GetStyles (perfil QGIS personalizado)

WFS capabilities

In the WFS capabilities area, you can select the layers that you want to publish as WFS, and specify if they will allow the update, insert and delete operations. If you enter a URL in the Advertised URL field of the WFS capabilities section, QGIS Server will advertise this specific URL in the WFS GetCapabilities response.

QGIS support the following request for WFS service:

  • GetCapabilities
  • DescribeFeatureType
  • GetFeature
  • Transacción

WCS capabilities

In the WCS capabilities area, you can select the layers that you want to publish as WCS. If you enter a URL in the Advertised URL field of the WCS capabilities section, QGIS Server will advertise this specific URL in the WCS GetCapabilities response.

Ahora, guardarmos la sesión en un archivo de proyecto alaska.qgs. Para proveer el proyecto como WMS/WFS, creamos una nueva carpeta /usr/lib/cgi-bin/project con privilegios de administrados y añadimos el archivo del proyecto alaska.qgs y copiamos del archivo qgis_mapserv.fcgi - eso es todo.

Now we test our project WMS, WFS and WCS. Add the WMS, WFS and WCS as described in Cargando capas WMS/WMTS, Cliente WFS y WFS-T and WCT Cliente to QGIS and load the data. The URL is:


QGIS support the following request for WCS service:

  • GetCapabilities
  • DescribeCoverage
  • GetCoverage

Ajuste fino de OWS

For vector layers, the Fields menu of the Layer ‣ Properties dialog allows you to define for each attribute if it will be published or not. By default, all the attributes are published by your WMS and WFS. If you want a specific attribute not to be published, uncheck the corresponding checkbox in the WMS or WFS column.

You can overlay watermarks over the maps produced by your WMS by adding text annotations or SVG annotations to the project file. See section Annotation Tools in Herramientas generales for instructions on creating annotations. For annotations to be displayed as watermarks on the WMS output, the Fixed map position check box in the Annotation text dialog must be unchecked. This can be accessed by double clicking the annotation while one of the annotation tools is active. For SVG annotations, you will need either to set the project to save absolute paths (in the General menu of the Project ‣ Project Properties dialog) or to manually modify the path to the SVG image in a way that it represents a valid relative path.

Parámetros extra soportados por la petición GetMap del WMS

In the WMS GetMap request, QGIS Server accepts a couple of extra parameters in addition to the standard parameters according to the OCG WMS 1.3.0 specification:

  • MAP parameter: Similar to MapServer, the MAP parameter can be used to specify the path to the QGIS project file. You can specify an absolute path or a path relative to the location of the server executable (qgis_mapserv.fcgi). If not specified, QGIS Server searches for .qgs files in the directory where the server executable is located.


  • Parámetro DPI: El parámetro DPI se puede utilizar para especificar la resolución de la solicitud de salida.


  • Parámetro OPACITIES: La opacidad se puede establecer en una capa o nivel de grupo. Los valores permitidos van de 0 (completamente transparente) a 255 (totalmente opaco).



QGIS Server logging

To log requests send to server, set the following environment variables:

  • QGIS_SERVER_LOG_FILE: Especifica la ruta y el nombre de archivo. Comprobar que el servidor tiene los permisos apropiados para escritura de archivo. El archivo debe ser creado automáticamente, sólo envié algunas solicitudes al servidor. Si no está allá, verifique los permisos.

  • QGIS_SERVER_LOG_LEVEL: Especifica el nivel de registro deseado. los valores disponibles son:

    • 0 INFO (registrar todas las solicitudes),


    • 2 CRÍTICA (Registrar sólo errores críticos, adecuado para fines de producción)


    SetEnv QGIS_SERVER_LOG_FILE /var/tmp/qgislog.txt


  • ¡Al usar el módulo Fcgid utilice FcgidInitialEnv en lugar de SetEnv!

  • Server logging is enabled also if executable is compiled in release mode.

Variables de entorno

  • QGIS_OPTIONS_PATH: The variable specifies path to directory with settings. It works the same ways as QGIS application –optionspath option. It is looking for settings file in <QGIS_OPTIONS_PATH>/QGIS/QGIS2.ini. For exaple, to set QGIS server on Apache to use /path/to/config/QGIS/QGIS2.ini settings file, add to Apache config:

    SetEnv QGIS_OPTIONS_PATH "/path/to/config/"