11.1. Lesson: QGISサーバーをインストールする
このレッスンの目標: Debian Stretchに QGIS Server をインストールする方法を学ぶこと。ごくわずかな変更で、Ubuntuやその派生版のようなDebianベースのディストリビューションでもこのレッスンに従うことができます。
注釈
Ubuntuでは、管理者権限を必要とするコマンドの前に sudo を付けて、通常のユーザーを使用することができます。Debianでは、sudo を使用せずに、管理者 (root) として作業することができます。
11.1.1.
Follow Along: パッケージからインストールする
In this lesson we're going to do only the install from packages as shown here .
QGISサーバーを以下でインストールします:
apt install qgis-server --no-install-recommends --no-install-suggests
# if you want to install server plugins, also:
apt install python-qgis
QGIS Server should be used in production without QGIS Desktop (with the accompanying X Server) installed on the same machine.
11.1.2.
Follow Along: QGISサーバー実行可能ファイル
QGISサーバー実行可能ファイルは、 qgis_mapserv.fcgi です。 /usr/lib/cgi-bin/qgis_mapserv.fcgi のような何かを出力する find / -name 'qgis_mapserv.fcgi' を実行して、どこにインストールされたかを確認できます。
Optionally, if you want to do a command line test at this time you can run the
/usr/lib/cgi-bin/qgis_mapserv.fcgi --version command which should output something
like:
QGIS 3.21.0-Master 'Master' (1c70953f1e)
QGIS code revision 1c70953f1e
Qt version 5.15.2
Python version 3.9.5
GDAL/OGR version 3.2.2
PROJ version 7.2.1
EPSG Registry database version v10.008 (2020-12-16)
GEOS version 3.9.0-CAPI-1.16.2
SQLite version 3.34.1
OS Ubuntu 21.04
We'll see later on how to make WMS requests.
11.1.3.
HTTP Server Configuration
In order to access on the installed QGIS server from an Internet Browser we need to use an HTTP server. The Apache HTTP Server installation process is detailed in Apache HTTP Server section.
注釈
If you installed QGIS Server without running an X Server (included in Linux
Desktop) and if you also want to use the GetPrint command then you should
install a fake X Server and tell QGIS Server to use it. You can do that by
following the Xvfb installation process.
11.1.4.
Follow Along: 別の仮想ホストを作成
QGISサーバーを指す別のApacheの仮想ホストを作成してみましょう。好きな名前を選択できます( coco.bango 、 super.duper.training 、 example.com、など)が、単純化のために myhost を使用するつもりです。
Let's set up the
myhostname to point to the localhost IP by adding127.0.0.1 xto the/etc/hostswith the following command:sh -c "echo '127.0.0.1 myhost' >> /etc/hosts"or by manually editing the file withgedit /etc/hosts.ターミナルで
ping myhostコマンドを実行することによって、myhostがlocalhostを指していることを確認できます。
qgis@qgis:~$ ping myhost
PING myhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.024 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.029 ms
curl http://myhost/cgi-bin/qgis_mapserv.fcgiしたり、DebianのボックスブラウザからURLにアクセスすることによって、myhostサイトからQGISサーバーにアクセスできるかどうか試してみましょう。おそらく得られるのは:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /cgi-bin/qgis_mapserv.fcgi was not found on this server.</p>
<hr>
<address>Apache/2.4.25 (Debian) Server at myhost Port 80</address>
</body></html>
Apache doesn't know that he's supposed to answer requests pointing to the server named
myhost. In order to setup the virtual host the simplest way would be to make amyhost.conffile in the/etc/apache2/sites-availabledirectory that has the same content asqgis.demo.confexcept for theServerNameline that should beServerName myhost. You could also change where the logs go as otherwise the logs for the two virtual hosts would be shared but this is optional.Let's now enable the virtual host with
a2ensite myhost.confand then reload the Apache service withservice apache2 reload.再度 http://myhost/cgi-bin/qgis_mapserv.fcgi URLにアクセスするために試してみると、すべてが今稼働していることに気づくでしょう!
11.1.5. In Conclusion
DebianベースのLinuxディストリビューション上で、QGISサーバーでApacheを設定する方法を、パッケージから異なるQGISサーバーのバージョンをインストールする方法を学びました。
11.1.6. What's Next?
Now that you've installed QGIS Server and it's accessible through the HTTP protocol, we need to learn how to access some of the services it can offer. The topic of the next lesson is to learn how to access QGIS Server WMS services.