7

What is the best way to add the QGIS Server capabilities to an existing web server running under Windows?

Specifically, I have WAMPServer 2.2 installed and running on Windows Server 2012, and would now like to add the capability to serve WFS layers. On a different machine (running Windows 7) I have successfully set up QGIS Desktop and Server via the OSGeo4W installer, but now I want to achieve the same result without installing a second version of Apache.

The tutorials I have found are either for linux/unix-type systems, are several years old and use pre-2.0 versions of QGIS, or use the OSGeo4W installer to create a new Apache installation.

I haven't been able to find an individual installer for a Windows version of QGIS Server, and it doesn't appear to be part of the QGIS Standalone Installer.

2 Answers 2

6

It turns out that this is a relatively straightforward process for Apache, but since I still haven't seen any walkthroughs for it online I figured I'd list the steps that worked for me here. I used the 64-bit version (of all components, OSGeo4W, Apache, and mod_fcgid) with Apache 2.4, but I presume the 32-bit version will be very similar, as will be other 2.x versions of Apache.

  1. Download and run the OSGeo4W(64) installer (https://www.qgis.org/en/site/forusers/download.html)

    • Choose the Advanced Install option, and then your installation source
    • Specify the root installation directory, which I'll refer to as %OSGEO%, and your other preferences on that screen
    • Choose where to store the installation files and how to get them, if you need the installer to download them
    • On the Select Packages screen, choose the two packages Desktop / qgis: QGIS Desktop and Web / qgis-server: QGIS Server, then click Next
    • Make sure that the Install these packages... option is checked when it prompts you about missing packages, and click Next again
  2. Once the installation is complete, copy %OSGEO%\httpd.d\httpd_qgis.conf to %APACHE%\conf\extras, where %APACHE% is the existing base directory of your Apache installation.

  3. Edit %APACHE%\conf\httpd.conf and add the following to the # Supplemental configuration section:

    • Include conf/extra/httpd_qgis.conf
  4. If you don't already have the Microsoft Visual C++ 2010 SP1 redistributable, download and install it (http://www.microsoft.com/download/en/details.aspx?id=13523)

    • If you don't know whether you have it, you can download and run it; you'll be prompted to repair or remove an existing installation, at which point you can cancel the installer
  5. Download the Apache FastCGI module (I found the 64-bit version of mod_fcgid at http://www.apachelounge.com/download/win64/)

    • Extract mod_fcgid/mod_fcgid.so to %APACHE%\modules
  6. Restart the Apache service

  7. You should be able to get a valid response from http://localhost/qgis/qgis_mapserv.fcgi.exe?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities

Update for Apache 2.4 security: I just went through this process again, with newer versions of the software: Apache 2.4.9 and QGIS 2.4. There was one additional step to gain access to the WMS. After following the above steps, trying to access the link in Step 7 gave a 403 Forbidden response. This is because the httpd_qgis.conf file included with QGIS uses the older Apache access directives Order allow,deny and Allow from all. If you encounter this problem, comment out those lines and add in Require all granted in their place.

1
  • Excellent. It is quite possible that afer this you still have to install some libs and dlls using the 64 bit installer to get it working if you are trying this for the first time ! Copy all DLLs from C:\OSGeo4W64\bin TO C:\OSGeo4W64\apps\qgis\bin
    – user48166
    Feb 26, 2015 at 22:34
0

It seems to be a common issue to copy some dlls into C:\OSGeo4W64\apps\qgis\bin. After a few days of trial-and-error it was quite simple to solve this problem: In httpd.conf is a link to httpd_qgis.conf. If this link appears before a FcgidInitialEnv or DefaultInitEnv directive, it will be overwritten by this new directive. Thus there is a missing path for the dlls in C:\OSGeo4W64\apps\qgis\bin and it won't work. Just make sure, the specific directive

FcgidInitialEnv PATH "C:\OSGeo4W64\bin;C:\OSGeo4W64\apps\qgis\bin;C:\OSGeo4W64\apps\grass\grass-6.4.3\bin;C:\OSGeo4W64\apps\grass\grass-6.4.3\lib;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"

appears at last (Use FcgidInitialEnv instead of DefaultInitEnv, cause it is deprecated).

Not the answer you're looking for? Browse other questions tagged or ask your own question.