Svarbu
Vertimas yra bendruomenės pastangos, prie kurių jūs galite prisijungti. Šis puslapis šiuo metu išverstas 66.09%.
2. Pradžia
2.1. Diegimas Debian-pagrindo sistemose
Mes pateiksime trumpą bet paprastą instrukciją, kaip sukurti minimalią veikiančią konfigūraciją Debian tipo sistemose (įskaitant Ubuntu ir jos išvestines). Dauguma kitų distribucijų ir OS teikia QGIS Serverio paketus.
Pastaba
Ubuntu jūs galite naudoti jūsų paprastą naudotoją, pridėdami sudo
prie komandų, kurioms reikia administravimo teisių. Debian sistemose jūs galite dirbti kaip administratorius (root
), nenaudodami sudo
.
Reikalavimai ir žingsniai, kaip pridėti oficialias QGIS repozitorijas ir įdiegti QGIS Serverį Debian tipo sistemose rasite QGIS diegimo puslapyje. Jūs tikriausiai norite įdiegti bent jau paskutinę Ilgo laikotarpio laidą (LTS).
Sukonfigūravus paskirties versijos repozitoriją ir įdiegus QGIS Serverį, jūs galite patikrinti diegimą su:
/usr/lib/cgi-bin/qgis_mapserv.fcgi
Jei gausite tokią išvestį, serveris teisingai įdiegtas.
Pastaba
Priklausomai nuo QGIS versijos, galite matyti šiek tiek kitokią išvestį, kai paleidžiate qgis_mapserv.fcgi
.
QFSFileEngine::open: No file name specified
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.
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.
Content-Length: 206
Content-Type: text/xml; charset=utf-8
<ServiceExceptionReport version="1.3.0" xmlns="https://www.opengis.net/ogc">
<ServiceException code="Service configuration error">Service unknown or unsupported</ServiceException>
</ServiceExceptionReport>
Pastaba
Kaip matote žemiau, QGIS grąžina būsenos kodą 400, kuris teisingai rodo, kad užklausa nepavyko, nes nėra aktyvios http sesijos. Tai nėra riktas ir nurodo, kad serveris veikia tinkamai.
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/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"
QFSFileEngine::open: No file name specified
Content-Length: 102
Content-Type: application/json
Server: QGIS FCGI server - QGIS version 3.40.0-Bratislava
Status: 400
[{"code":"Bad request error","description":"Requested URI does not match any registered API handler"}]
Pridėkime pavyzdinį projektą. Galite naudoti savo arba pateikiamą Demonstraciniuose mokymo duomenyse:
mkdir /home/qgis/projects/
cd /home/qgis/projects/
wget https://github.com/qgis/QGIS-Training-Data/archive/release_3.40.zip
unzip release_3.40.zip
mv QGIS-Training-Data-release_3.40/exercise_data/qgis-server-tutorial-data/world.qgs .
mv QGIS-Training-Data-release_3.40/exercise_data/qgis-server-tutorial-data/naturalearth.sqlite .
Žinoma galite naudoti jūsų mėgstamiausią GIS programinę įrangą, kad atvertumėte šitą failą ir pažiūrėtumėte konfigūraciją bei teikiamus sluoksnius.
Kad galėtumėte tinkamai naudoti QGIS serverį, jums reikės HTTP serverio. Rekomenduojami variantai yra Apache ar NGINX.
2.1.1. Apache HTTP Serveris
Pastaba
Žemiau keiskite qgis.demo
į jūsų serverio IP adresą.
Įdiekite Apache ir mod_fcgid:
apt install apache2 libapache2-mod-fcgid
Jūs galite paleisti QGIS Serverį jūsų numatytoje svetainėje, bet sukonfigūruokime atskirą virtualhost būtent tam, kaip pateikiama toliau.
Aplanke
/etc/apache2/sites-available
sukurkite failą, pavadintąqgis.demo.conf
su tokiu turiniu:<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName qgis.demo DocumentRoot /var/www/html # Apache logs (different than QGIS Server log) ErrorLog ${APACHE_LOG_DIR}/qgis.demo.error.log CustomLog ${APACHE_LOG_DIR}/qgis.demo.access.log combined # Longer timeout for WPS... default = 40 FcgidIOTimeout 120 FcgidInitialEnv LC_ALL "en_US.UTF-8" FcgidInitialEnv PYTHONIOENCODING UTF-8 FcgidInitialEnv LANG "en_US.UTF-8" # QGIS log FcgidInitialEnv QGIS_SERVER_LOG_STDERR 1 FcgidInitialEnv QGIS_SERVER_LOG_LEVEL 0 # default QGIS project SetEnv QGIS_PROJECT_FILE /home/qgis/projects/world.qgs # QGIS_AUTH_DB_DIR_PATH must lead to a directory writeable by the Server's FCGI process user FcgidInitialEnv QGIS_AUTH_DB_DIR_PATH "/home/qgis/qgisserverdb/" FcgidInitialEnv QGIS_AUTH_PASSWORD_FILE "/home/qgis/qgisserverdb/qgis-auth.db" # Set pg access via pg_service file SetEnv PGSERVICEFILE /home/qgis/.pg_service.conf FcgidInitialEnv PGPASSFILE "/home/qgis/.pgpass" # if qgis-server is installed from packages in debian based distros this is usually /usr/lib/cgi-bin/ # run "locate qgis_mapserv.fcgi" if you don't know where qgis_mapserv.fcgi is ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin/"> AllowOverride None Options +ExecCGI -MultiViews -SymLinksIfOwnerMatch Require all granted </Directory> <IfModule mod_fcgid.c> FcgidMaxRequestLen 26214400 FcgidConnectTimeout 60 </IfModule> </VirtualHost>
Pastaba
Kai kurios iš aukščiau matomų konfigūracijos parinkčių yra paaiškintos skiltyse Serverio aplinkos kintamieji ir pg_service faiilas.
Sukurkime aplankus, kuriuose bus saugomi QGIS Serverio žurnalai ir autentifikacijos duomenų bazė:
mkdir -p /var/log/qgis/ chown www-data:www-data /var/log/qgis mkdir -p /home/qgis/qgisserverdb chown www-data:www-data /home/qgis/qgisserverdb
Pastaba
www-data
yra Apache naudotojas Debian paremtose sistemose ir mums reikia, kad Apache galėtų pasiekti tas vietas ir failus.chown www-data...
komandos keičia atitinkamų aplankų ir failų savininkus įwww-data
.
Dabar galime įjungti virtualų mazgą ir
fcgid
modulį, jei tai dar nebuvo padaryta:a2enmod fcgid a2enmod rewrite a2ensite qgis.demo
Dabar iš naujo paleiskite Apache, kad įsigaliotų nauja konfigūracija:
systemctl restart apache2
Dabar, kai Apache žino, kad turi atsakinėti į užklausas, skirtas http://qgis.demo, mums taipogi reikia nustatyti kliento sistemą, kad ji žinotų, kas yra
qgis.demo
. Tai mes padarysime pridėdami127.0.0.1 qgis.demo
į hosts failą.# Replace 127.0.0.1 with the IP of your server. sh -c "echo '127.0.0.1 qgis.demo' >> /etc/hosts"
Svarbu
Prisiminkite, kad tiek qgis.demo.conf
, tiek /etc/hosts
failai turi būti sukonfigūruoti, kad jūsų nustatymai veiktų. Jūs taipogi galite patikrinti prieigą prie jūsų QGIS Serverio iš kitų tinklo klientų (pvz. Windows ar macos mašinų) eidami į jų /etc/hosts
failą ir nukreipdami vardą qgis.demo
į tokį serverio IP, kokiu jis pasiekiamas tinkle (ne 127.0.0.1
, nes tai yra vietinis IP, kuris pasiekiamas tik iš pačios mašinos). *nix
mašinose hosts
failą rasite /etc
, o Windows jis yra aplanke C:\Windows\System32\drivers\etc
. Jei naudojate Windows, jums reikės paleisti teksto redaktorių su administratoriaus teisėmis, kad galėtumėte atverti hosts failą.
QGIS Serveris dabar pasiekiamas http://qgis.demo. Norėdami patikrinti, įrašykite į naršyklę tokią paprastą užklausą:
http://qgis.demo/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities
2.1.2. NGINX HTTP Serveris
Pastaba
Žemiau keiskite qgis.demo
į jūsų serverio IP adresą.
Jūs taipogi galite naudoti QGIS Serverį su NGINX. Priešingai nei Apache, NGINX nemoka automatiškai pakelti FastCGI procesų. FastCGI procesus pakelti turi kas nors kitas.
Įdiekite NGINX:
apt install nginx
Kaip pirmą pasirinkimą galite naudoti spawn-fcgi ar fcgiwrap, kuris paleistų ir valdytų QGIS Serverio procesus. Abu turi oficialius Debian paketus. Jei neturite veikiančio X serverio ir jums reikia, pavyzdžiui, spausdinimo, galite naudoti xvfb.
Kitas variantas yra naudoti Systemd, GNU/Linux inicializavimo sistemą, kurią šiandien naudoja dauguma distribucijų. Vienas iš šio metodo pranašumų yra tas, kad tai nereikalauja jokių kitų komponentų ar procesų. Jis turėtų būti paprastas, bet stabilus ir efektyvus gamybos aplinkose.
NGINX konfigūracija
Svarbus ankstesnėje konfigūracijoje naudotas include fastcgi_params;, nes jis prideda parametrus iš /etc/nginx/fastcgi_params
:
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
Taipogi galite naudoti kai kuriuos Environment variables skirtus QGIS Serverio konfigūravimui. NGINX konfigūracijos faile, /etc/nginx/nginx.conf
, jūs turite naudoti instrukciją fastcgi_param
, kad apibrėžtumėte šiuos kintamuosius taip, kaip parodyta žemiau:
location /qgisserver {
gzip off;
include fastcgi_params;
fastcgi_param QGIS_SERVER_LOG_STDERR 1;
fastcgi_param QGIS_SERVER_LOG_LEVEL 0;
fastcgi_pass unix:/var/run/qgisserver.socket;
}
FastCGI įpakavimai
Įspėjimas
fcgiwrap lengviau paruošti nei spawn-fcgi, nes jis jau įpakuotas kaip Systemd paslauga. Bet tai taipogi veda į sprendimą, kuris yra daug lėtesnis nei naudojant spawn-fcgi. Su fcgiwrap, naujas QGIS Serverio procesas sukuriamas kiekvienam procesui, kas reiškia, kad QGIS Serverio inicializavimo procesas, kuriame yra ir QGIS projekto failo skaitymas ir nagrinėjimas, vykdomas kiekvienai užklausai. Su spawn-fcgi, QGIS Serverio procesas išlieka tarp užklausų, taip gaunant daug geresnę greitaveiką. Dėl šios priežasties gamyboje rekomenduojama naudoti spawn-fcgi.
spawn-fcgi
Jei norite naudoti spawn-fcgi:
Pirmas žingsnis yra įdiegti paketą:
apt install spawn-fcgi
Tada įterpkite tokį bloką į jūsų NGINX serverio konfigūraciją:
location /qgisserver { gzip off; include fastcgi_params; fastcgi_pass unix:/var/run/qgisserver.socket; }
Ir perstartuokite NGINX, kad būtų atsižvelgta į naują konfigūraciją:
systemctl restart nginx
O tada, jei nėra numatytojo spawn-fcgi paslaugos failo, jūs turite rankiniu būdu pradėti QGIS Serverį jūsų terminale:
spawn-fcgi -s /var/run/qgisserver.socket \ -U www-data -G www-data -n \ /usr/lib/cgi-bin/qgis_mapserv.fcgi
QGIS Serveris dabar pasiekiamas http://qgis.demo/qgisserver.
Pastaba
Kai naudojate spawn-fcgi, jūs galite tiesiogiai apibrėžti aplinkos kintamuosius prieš paleidžiant serverį. Pavyzdžiui: export QGIS_SERVER_LOG_STDERR=1
Be abejo, jūs galite pridėti init scenarijų, kuris paleistų QGIS Serverį sistemos paleidimo metu ar kada tik jūs norite. Pavyzdžiui su systemd:
Pakeiskite failą
/etc/systemd/system/qgis-server.service
šiuo turiniu:[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" ;; 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/qgis_mapserv.fcgi [Install] WantedBy=multi-user.target
Tada įjunkite ir paleiskite paslaugą:
systemctl enable --now qgis-server
Įspėjimas
Su aukščiau nurodytomis komandomis spawn-fcgi paleidžia tik vieną QGIS Server procesą.
fcgiwrap
Naudojant fcgiwrap nustatymas yra daug paprastesnis, nei su spawn-fcgi, bet jis daug lėtesnis.
Jūs visų pirma turite įdiegti atitinkamą paketą:
apt install fcgiwrap
Tada įterpkite tokį bloką į jūsų NGINX serverio konfigūraciją:
1 location /qgisserver { 2 gzip off; 3 include fastcgi_params; 4 fastcgi_pass unix:/var/run/fcgiwrap.socket; 5 fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/qgis_mapserv.fcgi; 6 }
Ir pabaigai perstartuoti NGINX ir fcgiwrap, kad būtų atsižvelgta į naują konfigūraciją:
systemctl restart nginx systemctl restart fcgiwrap
QGIS Serveris dabar pasiekiamas http://qgis.demo/qgisserver.
Systemd
Kad būtų pilnai panaudotas, konkrečiai spausdinimui, QGIS Serveriui reikia X Serverio. Jei jūs jau turite veikiantį X Serverį, jūs galite naudoti systemd paslaugas.
Šis QGIS Serverio paleidimo būdas remiasi dvejų Systemd vienetų konfigūracija: Jungties vienetas ir Paslaugos vienetas.
QGIS Serverio jungties vienetas apibrėžia ir sukuria failų sistemos jungtį, kurią NGINX naudoja QGIS Serverio paleidimui ir bendravimui su juo. Jungties vienetas turi būti sukonfigūruotas su
Accept=false
, kas reiškia, kad sisteminiaiaccept()
kvietimai perduodami procesui, kurį sukūrė Paslaugos vienetas. Jis yra/etc/systemd/system/qgis-server@.socket
, kuris realiai yra šablonas:[Unit] Description=QGIS Server Listen Socket (instance %i) [Socket] Accept=false ListenStream=/var/run/qgis-server-%i.sock SocketUser=www-data SocketGroup=www-data SocketMode=0600 [Install] WantedBy=sockets.target
Dabar įjunkite ir paleiskite jungtis:
for i in 1 2 3 4; do systemctl enable --now qgis-server@$i.socket; done
QGIS Serverio paslaugos vienetas apibrėžia ir paleidžia QGIS Serverio procesą. Svarbi dalis yra tai, kad paslaugos proceso standartinė įvestis prijungiama prie jungties, kuri apibrėžta jungties vienete. Tai turi būti sukonfigūruota naudojant
StandardInput=socket
paslaugos vieneto konfigūracijoje, kuri yra/etc/systemd/system/qgis-server@.service
:[Unit] Description=QGIS Server Service (instance %i) [Service] User=www-data Group=www-data StandardOutput=null StandardError=journal StandardInput=socket ExecStart=/usr/lib/cgi-bin/qgis_mapserv.fcgi EnvironmentFile=/etc/qgis-server/env [Install] WantedBy=multi-user.target
Pastaba
QGIS Serverio aplinkos kintamieji apibrėžiami atskirame faile
/etc/qgis-server/env
. Jis gali atrodyti taip:QGIS_PROJECT_FILE=/etc/qgis/myproject.qgs QGIS_SERVER_LOG_STDERR=1 QGIS_SERVER_LOG_LEVEL=3
Dabar paleiskite jungties paslaugą:
for i in 1 2 3 4; do systemctl enable --now qgis-server@$i.service; done
Na ir pabaigai, pridėkime šių nustatymų konfigūraciją NGINX HTTP serveriui:
upstream qgis-server_backend { server unix:/var/run/qgis-server-1.sock; server unix:/var/run/qgis-server-2.sock; server unix:/var/run/qgis-server-3.sock; server unix:/var/run/qgis-server-4.sock; } server { … location /qgis-server { gzip off; include fastcgi_params; fastcgi_pass qgis-server_backend; } }
Dabar iš naujo paleiskite NGINX, kad įsigaliotų nauja konfigūracija:
systemctl restart nginx
Ačiū Oslandia, kad pasidalino savo instrukcijomis.
2.1.3. Xvfb
QGIS Serveriui reikia veikiančio X Serverio, kad jis pilnai veiktų, konkrečiau, kad veiktų spausdinimas. Serveriuose paprastai rekomenduojama jo nediegti, taigi jums gali tekti naudoti xvfb
, kad turėtumėte virtualią X aplinką.
Jei jūsų Serveris veikia grafinėje/X11 aplinkoje, tai jums nereikia diegti xvfb. Daugiau informacijos rasite https://www.itopen.it/qgis-server-setup-notes/.
Kad įdiegtumėte paketą:
apt install xvfb
Sukurkite paslaugos failą
/etc/systemd/system/xvfb.service
su tokiu turiniu:[Unit] Description=X Virtual Frame Buffer Service After=network.target [Service] ExecStart=/usr/bin/Xvfb :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset [Install] WantedBy=multi-user.target
Įjunkite, paleiskite ir patikrinkite paslaugos
xvfb.service
būseną:systemctl enable --now xvfb.service systemctl status xvfb.service
Tada, pagal jūsų HTTP serverį, jūs turėtumėte sukonfigūruoti DISPLAY parametrą arba tiesiogiai naudoti xvfb-run.
Naudojant Apache:
Pridėkite jūsų Fcgid konfigūraciją (žr. Apache HTTP Serveris):
FcgidInitialEnv DISPLAY ":99"
Iš naujo paleiskite Apache, kad įsigaliotų nauja konfigūracija:
systemctl restart apache2
Naudojant NGINX
Su spawn-fcgi naudojant
xvfb-run
:xvfb-run /usr/bin/spawn-fcgi -f /usr/lib/cgi-bin/qgis_mapserv.fcgi \ -s /tmp/qgisserver.socket \ -G www-data -U www-data -n
Su DISPLAY aplinkos kintamuoju HTTP serverio konfigūracijoje.
fastcgi_param DISPLAY ":99";
2.2. Diegimas Windows sistemose
QGIS Serverį taipogi galima įdiegti Windows sistemose naudojant OSGeo4W tinklo diegiklį (https://qgis.org/resources/installation-guide/#windows).
Paprasta procedūra yra tokia:
Atsisiųskite ir paleiskite OSGeo4W diegiklį
Vykdykite „Išmanųjų diegimą“ ir įdiekite QGIS Darbastalį, QGIS Serverį apache ir mod_fcgid paketus.
Windows sistemoje apache nėra tiesiogiai diegiamas kaip paslauga. Jums reikia:
Spausti dešinį mygtuką ant failo
OSGeo4W.bat
aplankoC:\OSGeo4W\
šaknyje (jei buvo naudojami numatytieji diegimo keliai) ir parinkti Vykdyti kaip administratoriumiKonsolėje įvykdyti
apache-install.bat
, kuris išves> apache-install.bat Installing the 'Apache OSGeo4W Web Server' service The 'Apache OSGeo4W Web Server' service is successfully installed. Testing httpd.conf.... Errors reported here must be corrected before the service can be started. ...
Paslauga paleidžiama, kaip jūs ir matote ataskaitoje. Bet serveris gali ir nepasileisti dėl trūkstamos savos konfigūracijos.
Faile
C:\OSGeo4w\apps\apache\conf\httpd.conf
padarykite šiuos pakeitimus (galimos įvairios kitos kombinacijos):Tikslas
Esama konfigūracija
Pakeitimas
(Pasirinktinai) keiskite adresą, kuriuo klausytis, naudojant ip ir/ar prievadą. Jūs galite pridėti tiek įrašų, kiek tik norite.
Listen ${SRVPORT}
Listen localhost:8080
Nurodykite, kur rasti scenarijų failus
ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/"
ScriptAlias /cgi-bin/ "C:/OSGeo4W/apps/qgis/bin/"
Nurodykite scenarijų aplanko teises
<Directory "${SRVROOT}/cgi-bin"> AllowOverride None Options None Require all granted </Directory>
<Directory "C:/OSGeo4W/apps/qgis/bin"> SetHandler cgi-script AllowOverride None Options ExecCGI Require all granted </Directory>
Įjunkite failų plėtinį, kurį naudoti scenarijų failams. Atkomentuokite ir pabaikite
#AddHandler cgi-script .cgi
AddHandler cgi-script .cgi .exe
Pridėkite daugiau OSGeo4W savo konfigūracijos kintamųjų
# parse OSGeo4W apache conf files IncludeOptional "C:/OSGeo4W/httpd.d/httpd_*.conf"
# parse OSGeo4W apache conf files IncludeOptional "C:/OSGeo4W/httpd.d/httpd_*.conf" SetEnv GDAL_DATA "C:/OSGeo4W/share/gdal" SetEnv QGIS_AUTH_DB_DIR_PATH "C:/OSGeo4W/apps/qgis/resources"
Iš naujo paleiskite Apache serverį
> apache-restart.bat
Atverkite naršyklės langą QGIS Serverio GetCapabilities užklausos testavimui. Pakeiskite
localhost:8080
į IP ir prievadą, kuriuo nurodėte klausytis.http://localhost:8080/cgi-bin/qgis_mapserv.fcgi.exe?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities
Turėtų būti grąžintas
XML
failas su galimybėmis. Jūsų serveris paruoštas naudojimui.
2.3. Projekto pateikimas
Dabar, kai QGIS Serveris jau įdiegtas ir paleistas, jums reikia jį panaudoti.
Be abejo, jums reikia QGIS projekto, su kuriuo galėtumėte dirbti. Be abejo, jūs galite pilnai tinkinti savo projektą apibrėždami kontaktinę informaciją, apibrėžti CRS apribojimus ar net išimti kai kuriuos sluoksnius. Viskas, ką jums reikia apie tai žinoti, apibrėžta vėliau skyriuje Configure your project.
Bet pradžiai mes panaudosime paprastą projektą, kuris jau sukonfigūruotas ir anksčiau atsiųstas į /home/qgis/projects/world.qgs
, kaip aprašyta aukščiau.
Atvėrę projektą ir greitai peržiūrėję sluoksnius mes žinome, kad galimi 4 sluoksniai:
airports
places
countries
countries_shapeburst
Jums kol kas nereikia suprasti visos užklausos, bet jūs galite ištraukti žemėlapį su kai kuriais iš ankstesnių sluoksnių, QGIS Serverio dėka, padarius kažką panašaus į tai jūsų naršyklėje, kad parsiųstumėte sluoksnį „countries“.
Jei sekėte aukščiau pateiktas instrukcijas, kaip įdiegti Apache HTTP serverį:
http://qgis.demo/cgi-bin/qgis_mapserv.fcgi?MAP=/home/qgis/projects/world.qgs&LAYERS=countries&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS=EPSG:4326&WIDTH=400&HEIGHT=200&BBOX=-90,-180,90,180
Jei sekėte aukščiau pateiktas instrukcijas, kaip įdiegti NGINX HTTP serverį:
http://qgis.demo/qgisserver?MAP=/home/qgis/projects/world.qgs&LAYERS=countries&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS=EPSG:4326&WIDTH=400&HEIGHT=200&BBOX=-90,-180,90,180
Jei gaunate šį vaizdą, tai QGIS serveris veikia tvarkingai:

Fig. 2.2 Server response to a basic GetMap request
Note that you may define QGIS_PROJECT_FILE environment variable to use a project by default instead of giving a MAP parameter (see Environment variables).
For example with spawn-fcgi:
export QGIS_PROJECT_FILE=/home/qgis/projects/world.qgs
spawn-fcgi -f /usr/lib/bin/cgi-bin/qgis_mapserv.fcgi \
-s /var/run/qgisserver.socket \
-U www-data -G www-data -n
2.4. Configure your project
To provide a new QGIS Server WMS, WFS, OAPIF or WCS, you have to create a QGIS project file with some data or use one of your current projects. Define the colors and styles of the layers in QGIS and the project CRS, if not already defined. Then, go to the QGIS Server menu of the dialog and provide some information about the OWS in the Service Capabilities tab.

Fig. 2.3 Definitions for a QGIS Server WMS/WFS/WCS project
You have to Enable Service Capabilities first, if it is deactivated.
This will appear in the GetCapabilities response of the WMS, WFS or WCS.
If you don’t check Enable Service capabilities,
QGIS Server will use the information given in the
wms_metadata.xml
file
located in the cgi-bin
folder.
2.4.1. WMS capabilities

Fig. 2.4 Definitions in the WMS tab
In the WMS tab, you can define the options for the WMS capabilities.
Check Advertised extent to define the extent advertised in the WMS GetCapabilities response. The spatial extent selector widget helps you enter the extent as a
xmin, xmax, ymin, ymax
text or pick it from the map canvas, layers, bookmarks…
By checking
CRS restrictions, you can restrict in which coordinate reference systems (CRS) QGIS Server will offer to render maps. It is recommended that you restrict the offered CRS as this reduces the size of the WMS GetCapabilities response. Use the
button below to select those CRSs from the Coordinate Reference System Selector, or click Used to add the CRSs used in the QGIS project to the list.
If you have print layouts defined in your project, they will be listed in the
GetProjectSettings
response, and they can be used by the GetPrint request to create prints, using one of the print layouts as a template. This is a QGIS-specific extension to the WMS 1.3.0 specification. If you want to exclude any print layout from being published by the WMS, checkExclude layouts and click the
button below. Then, select a print layout from the Select print layout dialog in order to add it to the excluded layouts list.
If you want to exclude any layer or layer group from being published by the WMS, check
Exclude Layers and click the
button below. This opens the Select restricted layers and groups dialog, which allows you to choose the layers and groups that you don’t want to be published. Use the Shift or Ctrl key if you want to select multiple entries. It is recommended that you exclude from publishing the layers that you don’t need as this reduces the size of the WMS GetCapabilities response which leads to faster loading times on the client side.
Layer and Feature Options
You can receive requested GetFeatureInfo as plain text, XML and GML. The default is XML.
If you check
Use layer ids as name, layer ids will be used to reference layers in the
GetCapabilities
response orGetMap LAYERS
parameter. If not, layer name or short name if defined (see QGIS serverio savybės) is used.By default, layer names are used to expose layers through WMS. If multiple layers have the same name, they will be merged to a single WMS layer and cannot be requested individually. You need to take care of these layers being compatible with each other. Using the Use layer ids as name option ensures that multiple layers with the same name can be requested as individual layers.
If you wish, you can check
Add geometry to feature response. This will include the bounding box for each feature in the GetFeatureInfo response. See also the WITH_GEOMETRY parameter.
As many web clients can’t display circular arcs in geometries you have the option to segmentize the geometry before sending it to the client in a GetFeatureInfo response. This allows such clients to still display a feature’s geometry (e.g. for highlighting the feature). You need to check the
Segmentize feature info geometry to activate the option.
You can also use the GetFeatureInfo geometry precision option to set the precision of the GetFeatureInfo geometry. This enables you to save bandwidth when you don’t need the full precision.
If one of your layers uses the Map Tip display (i.e. to show text using expressions) this will be listed inside the GetFeatureInfo output. If the layer uses a Value Map for one of its attributes, this information will also be shown in the GetFeatureInfo output.
If you want QGIS Server to advertise specific request URLs in the WMS GetCapabilities response, enter the corresponding URL in the Advertised URL field.
Map and Legend Options
When a layer group is passed to
GetLegendGraphic
request, all of its leaf layers are added to the legend picture (however without the groups‘ labels). Check theAdd layer groups in GetLegendGraphic option if you want to also insert the layer groups (and subgroups) names into the layer tree, just like in QGIS Desktop legend.
When QGIS project contains layer groups, they are listed in WMS capabilities document alongside with layers. If a group (its name as listed in capabilities) is included in WMS GetMap
LAYERS
parameter alongside with names of layers in that group, QGIS would duplicate the layers: once for the group and once for specific layer. If you check theSkip name attribute for groups option, GetCapabilities will only return title attribute for the group but not its name attribute, making it impossible to include groups in list of layers of GetMap request.
Furthermore, you can restrict the maximum size of the maps returned by the requests by entering the maximum width and height into the respective fields under Maximum image size for GetMap and GetLegendGraphic requests.
You can change the Quality for JPEG and WebP images factor. The quality factor must be in the range 0 to 100. Specify 0 for maximum compression, 100 for no compression.
You can change the limit for atlas features to be printed in one request by setting the Maximum features for Atlas print requests field.
When QGIS Server is used in tiled mode (see TILED parameter), you can set the Tile buffer in pixels. The recommended value is the size of the largest symbol or line width in your QGIS project.
Depending on whether the map uses a projected CRS or a geographic CRS and if there is no information to evaluate the map unit sized symbols, you can provide reference for size through either a Default scale for legend or Default map units per mm in legend.
2.4.2. WMTS capabilities
In the WMTS tab you can select the layers you want to publish as WMTS and specify if you want to publish as PNG or JPEG.
Under Grids, for each restricted CRS,
you can indicate whether the tile matrices should be published
and configure their top-left corner, minimum and maximum scales
and the last level of the tile matrices.
Note that for EPSG:3857
and EPSG:4326
CRS, only the last level of the tile matrices can be edited.
You can also set a Minimum scale for the tiles display.
If you enter a URL in the Advertised URL field, QGIS Server will advertise this specific URL in the WMTS GetCapabilities response.

Fig. 2.5 Definitions in the WMTS tab
2.4.3. WFS/OAPIF capabilities
In the WFS/OAPIF tab, you can select the layers you want to publish as WFS or OAPIF, and specify if they will allow update, insert and delete operations.

Fig. 2.6 Definitions in the WFS/OAPIF tab
If you enter a URL in the Advertised URL field, QGIS Server will advertise this specific URL in the WFS GetCapabilities response.
2.4.4. WCS capabilities
In the WCS tab, you can select the layers that you want to publish as WCS.

Fig. 2.7 Definitions in the WCS tab
If you enter a URL in the Advertised URL field of the WCS capabilities section, QGIS Server will advertise this specific URL in the WCS GetCapabilities response.
2.4.5. Fine tuning your OWS
For vector layers, the Fields tab of the dialog allows you to define for each attribute if it will be published or not. By default, all the attributes are published by your WMS and WFS. If you don’t want a specific attribute to be published, uncheck the appropriate checkbox in the Configuration column:
Do not expose in WFS
Do not expose in WMS
You can overlay watermarks over the maps produced by your WMS by adding text annotations or SVG annotations to the project file. See the Anotacijų įrankiai section for instructions on creating annotations. For annotations to be displayed as watermarks on the WMS output, the Fixed map position checkbox in the Annotation text dialog must be unchecked. This can be accessed by double clicking the annotation while one of the annotation tools is active. For SVG annotations, you will need either to set the project to save absolute paths (in the General menu of the dialog) or to manually modify the path to the SVG image so that it represents a valid relative path.
2.5. Integration with third parties
QGIS Server provides standard OGC web services like WMS, WFS, etc. thus it can be used by a wide variety of end user tools.
2.5.1. Integration with QGIS Desktop
QGIS Desktop is the map designer where QGIS Server is the map server. The maps or QGIS projects will be served by the QGIS Server to provide OGC standards. These QGIS projects can either be files or entries in a database (by using
in QGIS Desktop).Furthermore, dedicated update workflow must be established to refresh a project used by a QGIS Server (ie. copy project files into server location and restart QGIS Server). For now, automated processes (as server reloading over message queue service) are not implemented yet.
2.5.2. Integration with MapProxy
MapProxy is a tile cache server and as it can read and serve any WMS/WMTS map server, it can be directly connected to QGIS server web services and improve end user experience.
2.5.3. Integration with QWC2
QWC2 is a responsive web application dedicated to QGIS Server. It helps you to build a highly customized map viewer with layer selection, feature info, etc.. Also many plugins are available like authentication or print service, the full list is available in this repository.