[Qgis-user] Qgis server postgis layers not valid (but desktop works on same machine)

Amedeo Fadini amefad at gmail.com
Tue Jul 8 01:43:19 PDT 2025


Hi jorge,
thank you very much your advice wer useful:

yes I checked permission of .pg_service.conf file and parent dir, same
thing happens also putting the file in other locations and chown-ing the
file to www-data.

Not sure where QGIS server should log in this configuration (there's a
sysadmin that manage installation in the server i will ask him to make a
separate log)
 but I found something in syslog.

It seems that thte variable PGSERVICEFILE  is not evaluated.
I've solved commenting the line and putting configuration in the
system-wide pgservice.conf  location /etc/postgresql.common

Next step is make GetPrint working... maybe I'll post another question
tomorrow :-)

amefad

Il giorno lun 7 lug 2025 alle ore 23:12 Jorge Gustavo Rocha via QGIS-User <
qgis-user at lists.osgeo.org> ha scritto:

> Hi Amedeo,
>
> Is the www-data user able to read the pg service file? If you didn't
> change the permissions, /home/ubuntu/.pg_service.conf is only readable by
> ubuntu user.
>
> Can you check the qgis server logs to see what is going on?
>
> Best regards,
>
> Jorge
> Às 21:05 de 07/07/25, Amedeo Fadini via QGIS-User escreveu:
>
> Errata corrige, the demo project works, the sqlite file was with wrong
> permission.
> Still doesn't load postgis layer
>
> Amedeo
>
> Il giorno lun 7 lug 2025 alle ore 21:54 Amedeo Fadini <amefad at gmail.com>
> ha scritto:
>
>> Hi everybody,
>>
>> I'm upgrading a project based on QGIS server and moved all stuff to new
>> server with Ubuntu 24, QGIS 3.40 LTR postgresql 16.
>> Webserver is nginx, QGIS server is configured on spawn-fcgi with single
>> socket follwing the qgis manual
>>
>> https://docs.qgis.org/3.40/en/docs/server_manual/getting_started.html#spawn-fcgi
>> The project use two layers from postgis, the connection is configured
>> with pg service
>>
>> Connecting on ssh with x.forwarding the project loads without any error
>> and works fine
>>
>> Calling the qgis server getcapabilities or get projectsettings it raise
>> the error
>> <ServerException>Layer(s) not valid</ServerException>
>> Setting QGIS_SERVER_IGNORE_BAD_LAYERS=true getcapabilities works but
>> postgis layer are not published or not showed in Getmap request.
>>
>> Any clue? Where can  I find more detailed erro log?
>>
>> even the demo project world.qgs gives balnk image in getmap request. Am I
>> misisng a local Xserver or gui configuration?
>>
>> Below is my nginx conf and systemd/system/qgis-server.service
>>
>> Thank you
>>
>> Amedeo Fadini
>>
>> ---
>> server {
>>     listen 80;
>>     server_name <my server name>;
>>
>>     location /qgis/ {
>>         include fastcgi_params;
>>         fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/qgis_mapserv.fcgi;
>>         #fastcgi_param  QGIS_DEBUG              1;
>>         fastcgi_param QGIS_SERVER_LOG_STDERR 1;
>>         #fastcgi_param QGIS_SERVER_LOG_LEVEL 0;
>>         fastcgi_param QGIS_SERVER_LOG_LEVEL 2;
>>         #fastcgi_param  PGSERVICEFILE /home/ubuntu/.pg_service.conf;
>>         #fastcgi_param  QGIS_PROJECT_FILE
>> /home/ubuntu/fiduciali_qgis/fiduciali.qgs;
>>         fastcgi_pass  unix:/var/run/qgisserver.socket;
>>     }
>> }
>>
>>
>> ---
>>
>> [Unit]
>> Description=QGIS server
>> After=network.target
>>
>> [Service]
>> ;; set env var as needed
>> ;Environment="LANG=en_EN.UTF-8"
>> ;Environment="QGIS_SERVER_PARALLEL_RENDERING=1"
>> ;Environment="QGIS_SERVER_MAX_THREADS=12"
>> Environment="QGIS_SERVER_LOG_LEVEL=0"
>> Environment="QGIS_SERVER_LOG_STDERR=1"
>> Environment="PGSERVICEFILE=/home/ubuntu/.pg_service.conf"
>> ;Environment="QGIS_PROJECT_FILE=/var/www/qgis_projects/world.qgs"
>> Environment="QGIS_PROJECT_FILE=/var/www/qgis_projects/fiduciali.qgs"
>> Environment="QGIS_SERVER_IGNORE_BAD_LAYERS=true"
>> ;; or use a file:
>> ;EnvironmentFile=/etc/qgis-server-env
>>
>> ExecStart=spawn-fcgi -s /var/run/qgisserver.socket -U www-data -G
>> www-data -n /usr/lib/cgi-bin>
>>
>> [Install]
>> WantedBy=multi-user.target
>>
>
> _______________________________________________
> QGIS-User mailing listQGIS-User at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
> --
> * Geomaster, LDA *
> * VENHA DESCOBRIR O CAMINHO DO OPEN SOURCE CONNOSC *
>
> Rua Afonso Palmeira, 31, 7 D
> 4715-278 Braga
> VAT/NIF 510 906 109
> Phone   +351 253 257 173
> Site geomaster.pt
> GPS 41.54627, -8.40432
> [image: Logo]
> ------------------------------
>
> Jorge Gustavo Rocha
> CTO
>
> Mobile   +351 910 333 888
> Email    jgr at geomaster.pt
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20250708/e0ed04f4/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cropped-geomaster300x300-1.png
Type: image/png
Size: 33896 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20250708/e0ed04f4/attachment-0001.png>


More information about the QGIS-User mailing list