[Qgis-user] Configuring QGIS server on Ubuntu 20.4

Mats Elfström mats.elfstrom at giskraft.se
Sat Oct 2 08:38:13 PDT 2021


Hi!
Let me just recuperate that the goal for QGIS server is to be used as a map
and data server for webmaps on MapStore and to be harvestable by Geonetwork
for a metadata catalogue. MapStore and Geonetwork are running on another
machine. QGIS server shall run on a Ubuntu machine, along with data in
PostGIS. The address for this machine is http://geonet.se
Essentially, I see QGIS Server as an equivalent to Geoserver but with
outstanding design capabilities.

Here comes a run-through of an attempt to install QGIS server on an Ubuntu
20.4 system, using these instructions:
https://docs.qgis.org/testing/en/docs/server_manual/getting_started.html#installation-on-debian-based-systems
The first step is to install QGIS, according to this page
https://qgis.org/en/site/forusers/alldownloads.html
I opted to install qgis-server by adding that in the last command as
suggested.
No problems so far. Only, when returning to the first manual page, I see
that I probably should have installed the LTR version instead of 3.20. If
this is important, the user should be advised earlier, and instructed how
to get the LTR version. For this review I will continue with 3.20.
Next, the user is again advised to install qgis-server and optionally
python-qgis. The motive for this is rather unclear at this stage, but I
chose to install python as advised.
Testing the installation by calling the fcgi seems to give a correct
response, even if it differs from the two samples. Notice error code 302
for instance.
root at geonet:~# /usr/lib/cgi-bin/qgis_mapserv.fcgi
Warning 1: Unable to find driver ECW to unload from GDAL_SKIP environment
variable.
Warning 1: Unable to find driver ECW to unload from GDAL_SKIP environment
variable.
Warning 1: Unable to find driver JP2ECW to unload from GDAL_SKIP
environment variable.
"Loading native module /usr/lib/qgis/server/libdummy.so"
"Loading native module /usr/lib/qgis/server/liblandingpage.so"
"Loading native module /usr/lib/qgis/server/libwcs.so"
"Loading native module /usr/lib/qgis/server/libwfs.so"
"Loading native module /usr/lib/qgis/server/libwfs3.so"
"Loading native module /usr/lib/qgis/server/libwms.so"
"Loading native module /usr/lib/qgis/server/libwmts.so"
Content-Length: 0
Location: http:/index.json
Server:  QGIS FCGI server - QGIS version 3.20.3-Odense
Status:  302

Next, it is suggested that I download a QGIS project or ‘use your own’ so I
manually created the /home/qgis/projects/ folder, and then saved a simple
QGIS project file to the folder. By default, this was saved in the qgz
format.
Then an HTTP server is needed.
A note says *In the following, please replace localhost with the name or IP
address of your server.*
But localhost only appears in the string webmaster at localhost where it
probably does not matter. There is no other mention of localhost in the
configuration file.
I go on to install Apache, as I have never used NGINX.
*You can run QGIS Server on your default website*
This is probably what I would want to do, but I do not know how, so I go on
to create a virtualhost as instructed by the name qgis.demo. I make the log
and qgisserverdb folders as instructed and set their permissions. Then I
enable fcgid and the site qgis.demo. The last command advises to run
systemctl reload apache2, but the manual suggests systemctl restart
apache2. I do both just to make sure. Then comes a tricky part, adding the
virtualhost to the hosts file. After that operation, it contains this. Note
that the server IP address got two definitions. I am bothered by this.
127.0.0.1   localhost
::1         localhost ip6-localhost ip6-loopback
ff02::1     ip6-allnodes
ff02::2     ip6-allrouters

# Auto-generated hostname. Please do not remove this comment.
206.72.203.32 geonet.se geonet
206.72.203.32 qgis.demo

Calling
http://qgis.demo/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities
from within the server gives


*<ServerException>Project file error. For OWS services: please provide a
SERVICE and a MAP parameter pointing to a valid QGIS project
file</ServerException>*

This seems correct. However, there is a totally confusing note here.
*Remember that both the myhost.conf and /etc/hosts files should be
configured for your setup to work. You can also test the access to your
QGIS Server from other clients on the network (e.g. Windows or macOS
machines) by going to their /etc/hosts file and point the myhost name to
whatever IP the server machine has on the network (not 127.0.0.1 as it is
the local IP, only accessible from the local machine). On *nix machines the
hosts file is located in /etc, while on Windows it’s under the
C:\Windows\System32\drivers\etc directory. Under Windows you need to start
your text editor with administrator privileges before opening the hosts
file.*
What is myhost.conf and what should it contain? The rest is very strange.
My goal is to access QGIS server from the internet, using the
http://geonet.se address, looked up by DNS as usual. Not from ‘other
clients on the network’ and the *myhost *name. What would be the point for
this? Not surprising,
http://geonet.se/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities
from the outside returns


*Not FoundThe requested URL was not found on this server.Apache/2.4.41
(Ubuntu) Server at geonet.se <http://geonet.se> Port 80 *
Doing just http://geonet.se returns the Apache2 Ubuntu Default Page
And here the show stops.

   - I might add that PostgreSQL and Geoserver are accessible from the
   outside, and Geoserver serves WMS to the Internet as expected. Port 80 is
   obviously open too.
   - I can also access QGIS server from QGIS desktop *on the same machine*,
   using http://qgis.demo as root. But I had to include a MAP request in
   the string, with a full path to the project file.


Conclusion: The missing piece of information seems to be how to make
Apache2 direct incoming requests to QGIS Server, OR how to configure QGIS
server to run as *your default website. *As all the rest depends on this,
it is a vital piece of information.

*Regards, Mats.E*

Den tors 30 sep. 2021 kl 21:25 skrev Alessandro Pasotti <apasotti at gmail.com
>:

>
> Hi, I'm sorry to hear that: we have even recently spent a considerable
> amount of time (and money, because it was financed with a grant) to rewrite
> the QGIS Server documentation with detailed information about deployment
> [1], we have clearly missed the goal if you couldn't find what you needed
> in these pages.
>
> It would be useful to know what exactly were your problems and what did
> you try to do.
>
> A common problem with server deployments is that there are multiple ways
> of doing things, it really depends on what you need, for example we are now
> commonly using docker containers (there are many out there that provide a
> QGIS Server working installation almost without the need to manually
> configure anything).
>
> Also, I tend to use nginx, but apache is totally fine too.
>
> [1]
> https://docs.qgis.org/3.16/en/docs/server_manual/getting_started.html#installation-on-debian-based-systems
>
>
> On Thu, Sep 30, 2021 at 8:24 PM Mats Elfström <mats.elfstrom at giskraft.se>
> wrote:
>
>> Hi!
>> I am setting up a Geodata stack. I have installed PostgreSQL/Postgis and
>> Geoserver under Tomcat9 and FME:d a lot of data to PostGIS. All is up and
>> running.
>> Then I installed QGIS 3.20. No problems so far. Then I decided to try
>> QGIS server as an alternative to Geoserver. But I am having trouble
>> configuring QGIS server, or Apache2 rather.
>> Over the past 5-6 years, I have spent more time and energy than I care to
>> mention trying to make QGIS server run on Windows servers. Asking for
>> advice on those occasions, I have more than once got the advice to use
>> Linux instead, since no QGIS developers really know Windows servers. And
>> Linux would be much easier.
>> Fair enough. So now I am on Ubuntu, sudoing this and that and it works
>> pretty well.
>> Apart from QGIS server. I find the same mess of incomplete or
>> contradictory instructions. No wonder QGIS server is under-used.
>> If Linux(Ubuntu) is so simple, how come no one has put together a working
>> script to configure and deploy QGIS server on a standard setup?
>> I am most disappointed, having spent yet 5 hrs that I will never get back
>> on QGIS server.
>>
>> Regards, Mats.E
>>
>> --
>>
>>
>> *GisKraft*, Geodatakonsult
>>
>> Mats Elfström, Marsvinsholms stationsväg 80, 271 93 Ystad, Sweden
>> tel: +46 70 595 39 35 / www.giskraft.se
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>
>
>
> --
> Alessandro Pasotti
> QCooperative:  www.qcooperative.net
> ItOpen:   www.itopen.it
>


-- 


*GisKraft*, Geodatakonsult

Mats Elfström, Marsvinsholms stationsväg 80, 271 93 Ystad, Sweden
tel: +46 70 595 39 35 / www.giskraft.se
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20211002/e2a84678/attachment-0001.html>


More information about the Qgis-user mailing list