Friday, 18 January 2019

Adding QGIS Server to an existing Windows web server


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.



Answer



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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...