QGIS Server on Windows7 Step-by-step

After my successful experiment with QGIS Server on Ubuntu, I took a shot at Windows7. These are my notes on installing QGIS Server following the instructions on the wiki.

Installation

Using OSGeo4W installer it is easy to install QGIS Server: Just mark qgis-server for installation from “Web” category (in the “Advanced” installation).

All other necessary packages will be selected automatically.

As mentioned on the wiki, the next step is to tell Apache which port number to use. Apache (2.2.14-4 from OSGeo4W) does not have any default IP/port set and it fails to start. To fix this, we need to edit the file

c:/osgeo4w/apache/conf/httpd.conf

and change

Listen @apache_port_number@

to our needs, e.g. to listen on port 80

Listen 80

The last thing I had to do to get QGIS Server working was to copy two files
libeay32.dll and ssleay32.dll
from C:\OSGeo4W\apache\bin
to C:\OSGeo4W\apps\qgis\bin.

The GetCapabilities request should work now

http://localhost/qgis/qgis_mapserv.fcgi.exe?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities

Adding a QGIS project file

To add a project file to the server, we stay in C:\OSGeo4W\apps\qgis\bin. If we put a project file in this directory, it will be served by default (without having to pass the optional map parameter).

For this test, I added my vienna.qgs project file. This is how my QGIS bin folder looks like (notice the .dll files we copied from Apache/bin and the project file):

Next, we have to restart Apache to force QGIS Server to load the project file. The OSGeo4W installation provides a handy “Apache-Monitor” GUI to restart Apache. If it fails, try to reboot ;)

Let’s test the setup using “Add WMS Layer” in QGIS by adding the service URL and ticking “Ignore GetMap URI …” and “Ignore GetFeature URI …”.

The project layers are now available through WMS and can be loaded into your client.

QGIS "Add WMS Layer" dialog with my newly created WMS

Conclusion

That wasn’t bad. The wiki page was very helpful and I didn’t encounter any real problems. Editing a config file and copying a few .dlls is easy enough.

Since linking files is not one of Windows’ strengths, I’d expect a server with multiple projects to get quite messy. But it certainly works for home use and experiments.

About these ads
21 comments
  1. Tim Couwelier said:

    First off: Thank you for this guide. Most of what I’ve seen is linux-based, and well.. I’m not too familiar with it, nor do I have the time to actually learn all about it. Somehow I didn’t feel ‘geek’ enough to try and get it solved under linux.

    So, if I get this correctly, it doesn’t require you to add the datasets to the folder that holds your project file?

    So if I would do the install, as you describe here, on our webserver.. I could have the project file refer to datasets on our fileserver (other machine, in same network). Therefor all of the datasets that are stored on the fileserver (and are aded to the project file) can be loaded through WMS from any machine within the network here.

    If so, that seems promissing. Adding all layers to the project file and have them load all on opening the project file tends be rather slow, and when limiting the datasets that are loaded on default, my collegues don’t usually know where to find the other dataset or how to load it (raster, vector, wms, ..).

    Bundeling it all into one WMS would make it far easier for them to load whatever they need (regardless of what type of data it is), as long as I have the display style set as needed in the project file….

    Seems like I need to go ahead and try this.

    Might I suggest from here onwards you make a tutorial on how to actually implement the WMS-server into a web-applet? (be it with OpenLayers, or whatever)
    Ideally, I’d wish for it to be able to display a vector dataset over OSM, and have it queryable.

    • Hi Tim,

      Thanks for your feedback.

      Both the Windows and Ubuntu example are done with project files that contain only layers from databases (PostGIS). I haven’t tested file data sources yet, so I cannot comment on where data files have to be copied.

      There are many OpenLayers examples using WMS available. QGIS Server is no different from any other WMS Server, so a dedicated tutorial would make no sense imho. The last paragraph of the Ubuntu post shows the necessary lines to add a QGIS Server WMS layer to an OpenLayers application.

      There is also QGIS Web Client which offers a lot of functionality but I haven’t tried configuring it yet.

  2. foe05 said:

    Dear Anita.
    Thank you for this blog post. It worked for me right away. Great success!
    The only question I had was answered by you to the previous comment.
    Ciao and good luck.

  3. peter said:

    Hi,

    thank you for this tutorial. I have tried the steps on Win XP. The GetCapabilities request worked!

    In the next step I mad a qgis project of only one layer from MySQL (only linestrings), filled the project properties and saved the projekt in

    C:\OSGeo4W\apps\qgis\bin\wasserleitungen.qgs

    Then I restarted apache, opend in qgis desktop an new project and added a WMS-layer with the following URL:

    http://localhost/qgis/qgis_mapserv.fcgi.exe?VERSION=1.3.0&map=C:/OSGeo4W/apps/qgis/bin/wasserleitungen.qgs

    After connecting the layer is shown in the list. But nothing is shown in the map. Only the coordinates on the bottom are correct. The apache logfile hase the following line:

    … “GET /qgis/qgis_mapserv.fcgi.exe?VERSION=1.3.0&map=C:/OSGeo4W/apps/qgis/bin/wasserleitungen.qgs&SERVICE=WMS&REQUEST=GetCapabilities HTTP/1.1″ 200 2912

    When I call the wms service from gaia I get an error message. You cn see it on the following adresses:

    Have you an idea, what I’ve made wrong?

    Thanks in davance!

    Best regards
    Peter

    • Hi Peter,

      I think only qgis-dev currently has MySQL support. QGIS Server might still be on version 1.7.x without MySQL support. To makes sure, please contact the mailing list.

  4. raynerhoward said:

    So far so good. Everything works perfectly. My next step is to get QGIS Web Client working under Windows 7 . . . I’ve tried just about everything. I have QGIS Web Client working beautifully under Ubuntu and Linux Mint.

    • batmanbatak said:

      would you kindly share it if you can figure how to make the qgis-web-client worked under windows 7.
      thanks

      • I will.
        Best wishes,
        Anita

  5. Miroslav Horvath said:

    Hi guys, I’m getting this error message when trying to connect to the WMS server:
    “Could not understand the response. The wms provider said:
    Download of capabilities failed: Error downloading http://localhost/qgis/qgis_mapserv.fcgi.exe?VERSION=1.3.0&map=C:/OSGeo4W/apps/qgis/bin/test.qgs&SERVICE=WMS&REQUEST=GetCapabilities – server replied: Not Found”
    … I’ve followed wiki tutorial to install and setup the tools(I just had to use different port as Skype was blocking the port 80) and they are running just fine. I’ve imported an existing shape file into the Qgis and saved it as test.qgs to c:\OSGeo4W\apps\qgis\bin\… but using this url “http://localhost/qgis/qgis_mapserv.fcgi.exe?VERSION=1.3.0&map=C:/OSGeo4W/apps/qgis/bin/test.qgs” Im getting the mentioned error… do you have any clue what could be the problem?

    Thanks in advance

    Regards,
    Miro

    • Did you tick “Ignore GetMap URI …” and “Ignore GetFeature URI …”? I updated the post to contain this info too.

      • Miroslav Horvath said:

        Thanks for the reply. No I didn’t… but I’m still having the same problem… I’ve gone through your tutorial once again and I’ve realized that
        “The GetCapabilities request should work now
        http://localhost/qgis/qgis_mapserv.fcgi.exe?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities
        doesn’t work for me. When I copy this link to my browser(firefox) nothing happens(I got a blank white page). What does it mean?
        Btw.

      • Sorry, I don’t know. Please contact the developer.

    • Miroslav Horvath said:

      Sorted out … Instead of “localhost” I have to use “127.0.0.1:255″(I’m using port 255, as 80 is being captured by skype)… everything works fine now… Thnx for the tutorial.

      • Thanks for posting the solution! Best wishes,
        Anita

  6. Yann LEGROS said:

    Hello Underdark. I tryed to follow strictly your instructions on “QGIS Server on Windows7 Step-by-step” and the GetCapabilities instruction works. My problem is that the WMS connection works on QGIS Desktop and the GetMap instruction works, but all the data are “blank”. Did you met the same problems ?
    Thanks in advance.
    Yann

    • Did you tick “Ignore GetMap URI …” and “Ignore GetFeature URI …”?

      • Yann LEGROS said:

        No I did not … Shame on me, now it works ! Thank you underdark, you save me.

  7. peter said:

    I did exacly as guide says. But no Luck.

    in httpd.conf i found this line already filled
    “# Change this to Listen on specific IP addresses as shown below to
    # prevent Apache from glomming onto all bound IP addresses.
    #
    #Listen 12.34.56.78:80
    Listen 80

    #
    # Dynamic Shared Object (DSO) Support”

    Apache is runnig because i get an OSGeo4w page after entering Localhost into my browser. But after entering http://localhost/qgis/qgis_mapserv.fcgi.exe?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities into browser, I got an Internal server error message. I did my instalation including Qgis yesterday.

  8. annyoed said:

    Does anyone really have any idea how to setup QGIS Server on Windows XP/7?? I’m following these instructions and have tried others too and always get the same result…..nothing. Having the same problem as peter. I can enter localhost into the browser and I get the PHPINFO page, but trying the GetCapabilites get me a 500 Internat Server Error

    • This comment section is not suitable to the task of debugging your setup. Please ask on gis.stackexchange or the QGIS mailing list and include any information on how you did the setup and what the Apache error log reads.

Follow

Get every new post delivered to your Inbox.

Join 3,187 other followers

%d bloggers like this: