4

I am trying to set up the QGIS Web Clients WSGI search. I've succefully set up my QGIS WebClient on a windows OS. Now I tried installing the mod_wsgi.so module in the Apache modules directory, added the line LoadModule modules wsgi_module / mod_wsgi.so always in apache but as soon as I plug in the conf apache:

 #mod_wsgi

 WSGIScriptAlias / WSGI "C: \ OSGeo4W \ apache \ htdocs \ qgis-web-client-master \ WSGI"      WSGIScriptAliasMatch ^ / WSGI / ([^ /] +) "C: \ OSGeo4W \ apache \ htdocs \ qgis -Web-client-master \ $ 1.wsgi"

The apache server does not reboot. I'd like to understand what am I doing wrong and how to further set up my apache to execute wsgi files?

1 Answer 1

3

QGIS Web Client's WSGI search requires you to configure your Apache into executing wsgi scripts. Firstly you'll need to install the correct module (When downloading a wsgi module please be sure to check the correct Apache version).

On the windows OS the configuration file can be found in the folder OSGeo4W/apache/conf/httpd.conf

Enable your module:

LoadModule wsgi_module modules/mod_wsgi.so

Now within the file OSGeo4W/httpd.d/httpd_qgis.conf we will configure our qgis application. This folder can contain definitions for qgis or any other kind of applications.

We will be adding 2 definitions, first one is the alias for wsgi:

Alias /wsgi/ C:\OSGeo4W/wsgi/  #**NOTE
#This will allow to change the path of the wsgi folder (which contains your wsgi/python scripts) to a shorter one -> /wsgi/

The second one is how and where we handle/execute these scripts:

<Directory "C:\OSGeo4W/wsgi/">
  SetHandler wsgi-script
  Options ExecCGI
  Order allow,deny
  Allow from all
</Directory>

**NOTE I've moved the wsgi scripts and the qgiswebclient/wsgi folder because the qwc_connect.py contains a database string, which is information I wouldn't like to share with the people using my Apache server

After these simple steps the Apache should reboot. If the Apache successfully rebooted the wsgi scripts are now supported.

The next step is setting up the wsgi scripts inside the /wsgi folder. In the file qwc_connect.py, we will now need to set up our database string:

DB_CONN_STRING="host='hostname' dbname='DATABASE_NAME' port='5432' user='myuser' password='mypassword'"

After we got our database string set, it is time to set the searchtables within the file search.wsgi, where we jump to line 32 and set:

searchtables = [sheme_name.table_name,...];

Now that we have our searchtable names set, we should define the views inside our database. Here is an example of create view script for PostgreSQL from michele's table:

CREATE OR REPLACE VIEW view_name_here AS --if you're using pgAdmin, remove this line 
SELECT 
concat ('Layer catasto_terreni: ', c.id,'-', c.foglio, '\', c.part_cat, ' ', c.comune) AS displaytext,
--this is the display text in your search box
concat(c.id,'\', c.foglio,'\', c.part_cat, '\', c.comune) AS search_category,
concat(c.part_cat, '/', c.foglio, '/', c.comune) AS searchstring,
--we perform searching by entering values parc_cat/foglio/comune, we can concat them to form more even complex strings, but I use a different view for each "type" of search
concat('') AS showlayer,
c.geom AS the_geom --this field is the most important one since it will zoom to this geometry
FROM catasto_terreni c;

This is an example of a search: QGIS Web Client search

13
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Midavalo
    Commented Feb 12, 2017 at 19:58
  • Oh thanks Midavalo, you can clear those comments up if possible...
    – Piskr
    Commented Feb 12, 2017 at 19:59
  • Hello Ena. Where could I find the material with respect to the description of the various text strings: dispalytext, search_category, searchstring, showLayer? Thank you
    – mchele
    Commented Mar 7, 2017 at 18:17
  • You can find all the information here: github.com/qgis/…
    – Piskr
    Commented Mar 7, 2017 at 18:48
  • I had already seen. The problem is that I do not understand exactly what are the searchstring and search_category functions.
    – mchele
    Commented Mar 7, 2017 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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