Closed webgis87 closed 1 year ago
I was having similar problem. This is how I managed to use the load the layers from PostgreSQL:
Configuration that I have:
[QgisServer+Lizmap+Postgres+Apache2] -- installed on a remote linux server (eg: testlizmap.com
)
I followed this guide on how to install qgisserver. under virtualhost conf it was referring to /home/qgis/.pg_service.conf
# Set pg access via pg_service file
SetEnv PGSERVICEFILE /home/qgis/.pg_service.conf
I therefore created that file and saved the login credentials there. example:
[qgistest]
host=localhost
port=5432
user=etienne
dbname=qgistest
password=my#123password!
I then restarted the apache service.
Now on my local windows computer where qgis desktop is installed, I followed this guide to add an Environment Variable named PGSERVICEFILE
with the path - e.g. C:\Users\John\pg_service.conf
.
In this pg_service.conf I used the same service name as above but changed the host=testlizmap.com
(as that is where my PostgreSQL database is located).
Then on the qgis desktop, I created a new PostgreSQL connection using the service qgistest
.
This worked for me. The layers added from database is visible from lizmap. But I am still confused as if this is the correct workflow one has to follow when pg_service.conf
is involved. I would be grateful if some of you could comment on this way of storing password as plain text files on server where qgisserver is installed and also on the desktop where qgis project files are edited.
One more thing, I added pg_service.conf
file also to /etc/postgresql-common/
as per the suggestion here. Without this file, lizmap was only showing the layers but was unable to edit them.
Can you explain what you did to fix your issue ? Maybe someone will find your question with a search engine with a similar issue.
What is the question?
Hello everyone, I'm having significant difficulties using layers in postgres. I don't want to save the credentials within the QGIS Project and would therefore like to use a pgservice file, as indicated by the official QGIS_SERVER guide, however without success someone would be kind enough to show me all the steps to use a pgservice to authenticate lizmap to the project.
If someone please show me precisely all the steps including any checks on postgres. Postgres opens correctly from QGIS on a different pc than the one where the database and lizmap resides, lizmap postgres are on the same system
Versions
QGIS322
Check Lizmap plugin
QGIS server version, only if the section above doesn't mention the QGIS Server version
3.22
Operating system
ubuntu 22.04
Browsers
Microsoft Edge
Browsers version
110
Relevant log output