EIngeloggt als root plus standard passwort für den ersten login nach Einrichtung des neuen IONOS VPS XS Server ## (1) Neuen User anlegen, damit nicht unter root gearbeitet wedren muss!! ##geouser ##geouserpasswort sudo adduser geouser; sudo usermod -aG sudo geouser ## Prüfen der ROOT Berechtigung su - geouser sudo ls / ## Ausloggen exit exit ##---------------------------------------------------------------------------------------- ## und mit neuem PUTTY Fenster als geouser wieder einloggen!!!! sudo apt update; sudo apt upgrade -y ## Anmerkung: sshd config behalten bestätigen "keep the local version currently installed" --------------- Prerequisits installieren Start ## Anleitung: https://docs.lizmap.com/3.8/en/install/py-qgis-server.html ## ---------------- ## We supposed, you already have installed QGIS Server packages, as explain in the QGIS Server documentation. ## ## ## QGIS >= 3.22 installed ## ## ** Installation entsprechend: https://qgis.org/resources/installation-guide/#debian--ubuntu ## ** Kurzer ausflug nach hier: https://qgis.org/resources/installation-guide/#available-codenames sudo wget https://download.qgis.org/downloads/qgis-archive-keyring.gpg; sudo gpg --no-default-keyring --keyring ./qgis-archive-keyring.gpg --list-keys ## **After you have verified the output you can install the key with: sudo cp qgis-archive-keyring.gpg /etc/apt/keyrings/qgis-archive-keyring.gpg ## ** With the keyring in place you can add the repository as /etc/apt/sources.list.d/qgis.sources with following content: sudo nano /etc/apt/sources.list.d/qgis.sources ## Inhalt von oben einfügen und sichern ## ------------- Inhalt ------------------------ Types: deb deb-src URIs: https://qgis.org/ubuntu-ltr Suites: noble Architectures: amd64 Components: main Signed-By: /etc/apt/keyrings/qgis-archive-keyring.gpg ## ------------------------------------- ## ** After that type the commands below to install QGIS: ## ** In case you would like to install QGIS Server, type: sudo apt update; sudo apt install qgis-server --no-install-recommends --no-install-suggests -y ## #Check QGIS Server version (optional) sudo apt-cache policy qgis-server ## # Test if QGIS server is running: /usr/lib/cgi-bin/qgis_mapserv.fcgi ## ---------- folgendes wird ausgegeben --------------------- geouser@ubuntu:~$ /usr/lib/cgi-bin/qgis_mapserv.fcgi Application path not initialized Application path not initialized Application path not initialized Application path not initialized 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/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.40.6-Bratislava Status: 302 ## ----------------------------------------------------------- ## ** QGIS Server sollte nun installiert sein! ##---------------------------------------------------------------------------------------- ## Im weiteren Verlauf wird PIP benötigt, daher nun: sudo apt install pip -y ##---------------------------------------------------------------------------- ## Hier sollten alle Prerequisits installiert sein! ##---------------------------------------------------------------------------- ## Install in a Python venv ## ## We add needed packages not provided with QGIS Server : sudo apt install python3-venv python3-psutil -y ## Then, we create the Py-QGIS-Server virtual environment and install py-qgis-server with pip : set -e sudo python3 -m venv /opt/local/py-qgis-server --system-site-packages ## Beobachtung: Hier stürzte putty manchmal ab, in dem Fall putty neustart, neu einloggen und nochmals ausführen!! sudo python3 -m venv /opt/local/py-qgis-server --system-site-packages sudo /opt/local/py-qgis-server/bin/pip install -U pip setuptools wheel pysocks typing py-qgis-server ## ---------- Führt zu folgender Ausgabe --------------- ## ## Attempting uninstall: pip ## Found existing installation: pip 24.0 ## Uninstalling pip-24.0: ## Successfully uninstalled pip-24.0 ## Successfully installed pip-25.1.1 py-qgis-server-1.9.4 pysocks-1.7.1 pyzmq-26.4.0 setuptools-80.3.1 tornado-6.4.2 typing-3.7.4.3 wheel-0.45.1 ## ## ----------------------------------------------------- ## Py-QGIS-Server is installed. ## Configuration and associated files ## Folders used below sudo mkdir -p /srv/qgis/plugins /srv/qgis/config /var/log/qgis /var/lib/py-qgis-server /var/data ## The file to watch for restarting workers ## We create an empty file that will be watch by Py-QGIS-Server to check when to restart QGIS Server map workers. sudo touch /var/lib/py-qgis-server/py-qgis-restartmon; sudo chmod 664 /var/lib/py-qgis-server/py-qgis-restartmon ## The bash file to restart workers ## We create the executable file /usr/bin/qgis-reload to restart QGIS Server map workers. It will contain: sudo nano /usr/bin/qgis-reload ------------ Inhalt ---------------------- #!/bin/bash touch /var/lib/py-qgis-server/py-qgis-restartmon ------------------------------------------ ## Then we when change its mod : sudo chmod 750 /usr/bin/qgis-reload ## The configuration file ## We create the Py-QGIS-Server configuration file /srv/qgis/server.conf. It will contain: sudo nano /srv/qgis/server.conf ------------ Inhalt ---------------------- # # Py-QGIS-Server configuration # https://docs.3liz.org/py-qgis-server/ # [server] port = 7200 interfaces = 127.0.0.1 workers = 4 pluginpath = /srv/qgis/plugins timeout = 200 restartmon = /var/lib/py-qgis-server/py-qgis-restartmon [logging] level = info [projects.cache] strict_check = false rootdir = /srv/data size = 50 advanced_report = no [monitor:amqp] routing_key = default_routing_key= host = [api.endpoints] lizmap_api=/lizmap [api.enabled] lizmap_api=yes ------------------------------------------ ## Manage it with systemd ## First of all, we create an environment file /srv/qgis/config/qgis-service.env with sudo nano /srv/qgis/config/qgis-service.env ------------ Inhalt ---------------------- LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 DISPLAY=:99 QGIS_OPTIONS_PATH=/srv/qgis/ QGIS_AUTH_DB_DIR_PATH=/srv/qgis/ GDAL_CACHEMAX=2048 QGIS_SERVER_CACHE_SIZE=2048 QGIS_SERVER_LIZMAP_REVEAL_SETTINGS=TRUE QGIS_SERVER_FORCE_READONLY_LAYERS=TRUE QGIS_SERVER_TRUST_LAYER_METADATA=TRUE QGIS_SERVER_APPLICATION_NAME=qgis-server ------------------------------------------ ## Then we can create the QGIS service systemd file /etc/systemd/system/qgis.service with sudo nano /etc/systemd/system/qgis.service ------------ Inhalt ---------------------- [Unit] Description=QGIS server After=network.target [Service] Type=simple ExecStart=/opt/local/py-qgis-server/bin/qgisserver -c /srv/qgis/server.conf # FIXME it is recommended to have a script *synchronous*, which is not the case here ExecReload=/usr/bin/qgis-reload KillMode=control-group KillSignal=SIGTERM TimeoutStopSec=10 Restart=always StandardOutput=append:/var/log/qgis/qgis-server.log StandardError=inherit SyslogIdentifier=qgis EnvironmentFile=/srv/qgis/config/qgis-service.env User=root LimitNOFILE=4096 [Install] WantedBy=multi-user.target ------------------------------------------ ## Finally, we enable the QGIS Server service to start it and to be sure it is started at system launch : sudo systemctl enable qgis; sudo service qgis start ## 1. We can check that QGIS Server with Py-QGIS-Server is working with : curl http://127.0.0.1:7200/ows/ sudo curl http://127.0.0.1:7200/ows/ ## Das führt zu folgendem: ## ----------------------------------------------------------------------- ## curl: (7) Failed to connect to 127.0.0.1 port 7200 after 0 ms: Couldn't connect to server ## ----------------------------------------------------------------------- ## Prüfung, ob der Service überhaupt läuft!! sudo service qgis status ## Das führt zu folgendem: ## ----------------------------------------------------------------------- ## × qgis.service - QGIS server ## Loaded: loaded (/etc/systemd/system/qgis.service; enabled; preset: enabled) ## Active: failed (Result: exit-code) since Wed 2025-05-07 12:00:03 UTC; 22min ago ## Duration: 992ms ## Process: 851 ExecStart=/opt/local/py-qgis-server/bin/qgisserver -c /srv/qgis/server.conf (code=exited, status=1/FAILURE) ## Main PID: 851 (code=exited, status=1/FAILURE) ## CPU: 984ms ## ## May 07 12:00:03 ubuntu systemd[1]: qgis.service: Scheduled restart job, restart counter is at 5. ## May 07 12:00:03 ubuntu systemd[1]: qgis.service: Start request repeated too quickly. ## May 07 12:00:03 ubuntu systemd[1]: qgis.service: Failed with result 'exit-code'. ## May 07 12:00:03 ubuntu systemd[1]: Failed to start qgis.service - QGIS server. ## ## ----------------------------------------------------------------------- Damit war ich mit meinem Latein erstmal am Ende!! ## Dann fiel mir noch auf, dass in /srv/qgis/server.conf rootdir = /srv/data definiert ist, es dieses Verzeichnis aber nicht gibt. ## Daher angelegt mit: sudo mkdir -p /srv/data ## qgis service neu gestartet mit: sudo service qgis start; sudo service qgis status ## Das führt zu folgendem: ## ----------------------------------------------------------------------- ● qgis.service - QGIS server Loaded: loaded (/etc/systemd/system/qgis.service; enabled; preset: enabled) Active: active (running) since Wed 2025-05-07 13:07:04 UTC; 3s ago Main PID: 27449 (qgisserver) Tasks: 9 (limit: 977) Memory: 83.4M (peak: 109.4M) CPU: 913ms CGroup: /system.slice/qgis.service ├─27449 /opt/local/py-qgis-server/bin/python3 /opt/local/py-qgis-s> └─27450 /opt/local/py-qgis-server/bin/python3 /opt/local/py-qgis-s> May 07 13:07:03 ubuntu systemd[1]: qgis.service: Failed with result 'exit-code'. May 07 13:07:03 ubuntu systemd[1]: qgis.service: Consumed 1.036s CPU time. May 07 13:07:04 ubuntu systemd[1]: qgis.service: Scheduled restart job, restart> May 07 13:07:04 ubuntu systemd[1]: Started qgis.service - QGIS server. ## -------------------------------------------------------------------- ## nun nochmal: check that QGIS Server with Py-QGIS-Server is working with : curl http://127.0.0.1:7200/ows/ sudo curl http://127.0.0.1:7200/ows/ #mit oder ohne sudo ## Das führt zu folgendem: ## ----------------------------------------------------------------------- geouser@ubuntu:/var/data$ curl http://127.0.0.1:7200/ows/ curl: (52) Empty reply from server ## --------------------------------------------------------------------