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



At this point, we will give a short and simple sample installation how-to for a minimal working configuration using Apache2 on Debian/Ubuntu. The first step is QGIS Server installation whose instructions are provided in QGIS installers page.

Configureren van de HTTP-server


Installeer de Apache server in een afzonderlijke virtual host luisterend naar poort 80. Schakel de module rewrite in om HTTP BASIC auth headers door te kunnen geven:

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

Dit is de configuratie voor de virtual host, opgeslagen in /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

 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

Schakel nu de virtual host in en start Apache opnieuw:

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


You can use QGIS Server with nginx.

On Debian based systems:

apt-get install nginx fcgiwrap

Introduce the following in your nginx server block configuration:

  location ~ ^/cgi-bin/.*\.fcgi$ {
      gzip           off;
      include fastcgi_params;
      fastcgi_pass   unix:/var/run/fcgiwrap.socket;

      fastcgi_param  SCRIPT_FILENAME /usr/lib/cgi-bin/qgis_mapserv.fcgi;
      fastcgi_param  QGIS_SERVER_LOG_FILE /logs/qgisserver.log;
      fastcgi_param  QGIS_SERVER_LOG_LEVEL 0;
      fastcgi_param  QGIS_DEBUG 1;

As you can see from lines 6-9 you can add parameters in your location block in the form of fastcgi_param param_name param_value, e.g. fastcgi_param  DISPLAY ":99";.

The include fastcgi_params; is important as it adds the parameters from /etc/nginx/fastcgi_params:

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REQUEST_SCHEME     $scheme;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

Prepare a project to serve

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.


Definities voor een project QGIS Server WMS/WFS/WCS

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.


If you’re using the QGIS project with styling based on SVG files using relative paths then you should know that the server considers the path relative to its qgis_mapserv.fcgi file (not to the qgs file). So, if you deploy a project on the server and the SVG files are not placed accordingly, the output images may not respect the Desktop styling. To ensure this doesn’t happen, you can simply copy the SVG files relative to the qgis_mapserv.fcgi. You can also create a symbolic link in the directory where the fcgi file resides that points to the directory containing the SVG files (on Linux/Unix).


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 signPlus button below to select those CRSs from the Coordinate Reference System Selector, or click Used to add the CRSs used in the QGIS project to the list.

If you have print composers defined in your project, they will be listed in the GetProjectSettings 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 signPlus 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 signPlus 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.

U kunt de door u verzochte GetFeatureInfo als platte tekst, XML en GML ontvangen. XML is standaard, de indelingen tekst of GML zijn afhankelijk van de indeling die wordt gekozen in het verzoek GetFeatureInfo.

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.

Als één van uw lagen de weergave Map Tip display (d.i. om tekst met behulp van expressies weer te geven) zal dit worden vermeld binnen de uitvoer van GetFeatureInfo. Als de laag een Value Map gebruikt voor één van zijn attributen, wordt die informatie ook weergegeven in de uitvoer van GetFeatureInfo.


In het gebied WFS-mogelijkheden kunt u de lagen selecteren die u wilt publiceren als WFS, en specificeren of zij de bewerkingen Bijwerken, Toevoegen en Verwijderen zullen toestaan. Als u een URL invoert in het veld Opgegeven URL van het gedeelte WFS-mogelijkheden, zal QGIS Server deze specifieke URL opnemen in het antwoord WFS GetCapabilities.


In het gebied WCS-mogelijkheden kunt u de lagen selecteren die u wilt publiceren als WCS. Als u een URL invoert in het veld Opgegeven URL van het gedeelte WCS-mogelijkheden, zal QGIS Server deze specifieke URL opnemen in het antwoord van WCS GetCapabilities.

Fijn afstemmen van uw OWS

Voor vectorlagen geeft het menu Velden van het dialoogvenster Laag ‣ Eigenschappen u de mogelijkheid om voor elk attribuut te definiëren of het mag worden gepubliceerd of niet. Standaard worden alle attributen gepubliceerd door uw WMS en WFS. Als u een specifiek attribuut niet wilt publiceren, deselecteer dan het overeenkomende keuzevak in de kolom WMS of WFS.

You can overlay watermarks over the maps produced by your WMS by adding text annotations or SVG annotations to the project file. See the Gereedschappen voor annotatie section for instructions on creating annotations. For annotations to be displayed as watermarks on the WMS output, the Fixed map position checkbox 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 so that it represents a valid relative path.

Serve the project

Now, save the session in a project file alaska.qgs. To provide the project as a WMS/WFS, create a new folder /usr/lib/cgi-bin/project with admin privileges and add the project file alaska.qgs and a copy of the qgis_mapserv.fcgi file - that’s all.

Now test your project WMS, WFS and WCS. Add the WMS, WFS and WCS as described in Laden van lagen WMS/WMTS, WFS- en WFS-T-cliënt and WCS-cliënt to QGIS and load the data. The URL is:


Cascading OGC layers

A QGIS project can of course contain layers coming from remote OGC servers (regardless of the underlying OGC server software used). This way QGIS will effectively cascade those layers through its OGC (QGIS Server based) services.

If the external OGC layers are coming from services that make use of the HTTPS protocol you must take care of some extra QGIS Server configuration. Example for the Apache web server:

$ mkdir /srv/qgis/.qgis2
$ chown www-data:www-data /srv/qgis/.qgis2
$ chmod 774 /srv/qgis/.qgis2

This ensures that the web server is able to write in some user defined folder. Then add the following line to the Apache virtual host file to ensure that Apache will use such folder:

FcgidInitialEnv HOME "/srv/qgis"

Restart Apache.