5. Plugin
5.1. Elenco dei plugin
Plugins can also be installed on QGIS Server.
Alcuni plugin progettati per il server si trovano nel repository ufficiale di QGIS.
Install only plugins you need for your own purpose. On QGIS server, plugins are like hooks into QGIS server, they can alter inputs or outputs of QGIS server. They can produce unexpected result if you don’t know how the plugin works. Please refer to their respective documentation or the application that needs QGIS server plugins to know which plugin can be useful for you.
5.2. Ubicazione dei plugin
Per impostazione predefinita, sui sistemi basati su Debian, QGIS Server cercherà i plugin situati in /usr/lib/qgis/plugins
. Il valore predefinito viene visualizzato all’avvio di QGIS Server, nei log. È possibile impostare un percorso personalizzato definendo la variabile d’ambiente QGIS_PLUGINPATH
nella configurazione del server web.
5.3. Installazione
5.3.1. Manualmente con uno ZIP
As an example, to install the HelloWorld plugin for testing the server, using a specific folder, you first have to create a directory to hold server plugins. This will be specified in the virtual host configuration and passed on to the server through an environment variable:
mkdir -p /var/www/qgis-server/plugins
cd /var/www/qgis-server/plugins
wget https://github.com/elpaso/qgis-helloserver/archive/master.zip
unzip master.zip
mv qgis-helloserver-master HelloServer
Avvertimento
According to its description, HelloServer plugin is designed for development and demonstration purposes. Do not keep this plugin for production if you don’t need it.
5.3.2. Con uno strumento a linea di comando
Se hai bisogno di installare e aggiornare regolarmente i plugin che sono memorizzati nel repository dei plugin di QGIS, puoi usare il QGIS-Plugin-Manager. È uno strumento che aiuta a gestire i plugin dalla linea di comando.
L’installazione avviene tramite pip. L’installazione in un ambiente virtuale è una buona pratica, ma non è obbligatoria:
pip3 install qgis-plugin-manager
To upgrade the tool:
pip3 install --upgrade qgis-plugin-manager
Quindi, puoi utilizzare l’eseguibile qgis-plugin-manager
dalla linea di comando:
cd /var/www/qgis-server/plugins
qgis-plugin-manager list
QGIS server version 3.19.0
List all plugins in /var/www/qgis-server/plugins
------------------------------------------------------------------------------------------------------------------------------------------------------
| Folder | Name | Version | Experimental | QGIS min | QGIS max | Author | Action ⚠ |
------------------------------------------------------------------------------------------------------------------------------------------------------
|wfsOutputExtension |wfsOutputExtension|1.6.2 | |3.0 | |3Liz | |
|qgis_server_render_geojson|GeoJson Renderer |v0.4 | |3.4 | |Matthias Kuhn (OPENGIS.ch)| |
|DataPlotly |Data Plotly |3.7.1 | |3.4 |3.98 |Matteo Ghetta (Faunalia) |Upgrade to 3.8.1 |
------------------------------------------------------------------------------------------------------------------------------------------------------
Si consiglia di leggere la documentazione completa nel file readme per sapere come installare o aggiornare i plugin con questo strumento.
5.4. Configura il server HTTP
5.4.1. Apache
Per poter utilizzare i plugin del server, FastCGI deve sapere dove cercare. Quindi, dobbiamo modificare il file di configurazione di Apache per indicare a FastCGI la variabile d’ambiente QGIS_PLUGINPATH
:
FcgidInitialEnv QGIS_PLUGINPATH "/var/www/qgis-server/plugins"
Inoltre, un’autorizzazione HTTP di base è necessaria per lavorare con il plugin HelloWorld precedentemente introdotto. Quindi dobbiamo aggiornare il file di configurazione di Apache un’ultima volta:
# Needed for QGIS HelloServer plugin HTTP BASIC auth
<IfModule mod_fcgid.c>
RewriteEngine on
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Poi, riavvia Apache:
systemctl restart apache2
5.5. Come usare un plugin
Fai il test il server con il plugin HelloWorld:
wget -q -O - "http://localhost/cgi-bin/qgis_mapserv.fcgi?SERVICE=HELLO"
HelloServer!
Puoi dare un’occhiata al GetCapabilities di default del server QGIS su:
http://localhost/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities