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.



HTTP BASIC認証ヘッダを渡すように書き換えモジュールを有効にするポート 80 でリッスンして別の仮想ホストにApacheサーバーをインストールします。

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

これは仮想ホストの設定で、 /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


$ 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.


QGISサーバーの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.


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.

レイヤーの一つが 地図ヒントディスプレイ を使用している場合(つまり式を使ってテキストを表示するために)これはGetFeatureInfo出力内で表示されます。レイヤーは、その属性のいずれかの値マップを使用している場合は、この情報には、GetFeatureInfo出力に表示されます。


でWFS機能 エリアWFSとして公開し、それらが更新を許可するかどうかを指定、操作を挿入し、削除したいレイヤーを選択できます。 :guilabel:` WFS機能` セクションの 宣伝URL フィールドにURLを入力すると、QGIサーバーは、WFSのGetCapabilities応答中でこの特定のURLを宣伝します。


WCS機能 エリア、WCSとして公開したいレイヤーを選択できます。 WCS機能 セクションで 宣伝URL フィールドにURLを入力すると、QGISサーバーはWCSのGetCapabilities応答でこの特定のURLを宣伝します。


ベクターレイヤーの場合は、 レイヤー ‣ のプロパティ ダイアログの フィールド メニューで、各属性ごとにそれが公開されるかされないか定義できます。デフォルトではすべての属性がWMSとWFSによって公開されます。特定の属性が公開されたくない場合は、 WMS または 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 注記ツール 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 WMS/WMTS レイヤーを読み込む, WFS および WFS-T クライアント and WCS クライアント 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.