end0tknr's kipple - 新web写経開発

http://d.hatena.ne.jp/end0tknr/ から移転しました

install postgres 9.6 & postgis 2.3 & mapserver & mapserver 7.0

5~6年ぶりに postgres と postgis をinstall.

mapserverがcmakeに対応した点以外では、 しばらく使ってなかった割に変化点は多くありませんでした。

PostgreSQL: The world's most advanced open source database

PostGIS — Spatial and Geographic Objects for PostgreSQL

Welcome to MapServer — MapServer 7.0.6 documentation

mac osx 10.6.3にpostgis, mapserverをinstall - end0tknr's kipple - 新web写経開発

国土交通省にあるGISデータをPostGISへインポート(改訂版) - end0tknr's kipple - 新web写経開発

install postgres

$ wget https://ftp.postgresql.org/pub/source/v9.6.5/postgresql-9.6.5.tar.gz
$ tar -xvf postgresql-9.6.5.tar.gz
$ cd postgresql-9.6.5
$ less INSTALL
$ ./configure
$ make
$ make check
$ su
# make install
# adduser postgres
# mkdir /usr/local/pgsql/data
# chown postgres /usr/local/pgsql/data
# su - postgres
$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
$ /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
$ /usr/local/pgsql/bin/createdb test
$ /usr/local/pgsql/bin/psql test

# cd /etc/rc.d/init.d/
# cp /tmp/postgresql-9.6.5/contrib/start-scripts/linux ./postgres
# vi postgres
# chmod 755 postgres
# /sbin/chkconfig --add postgres
# /sbin/chkconfig --list postgres

install postgis

http://postgis.net/source/

Prerequisites

## GEOS
$ wget http://download.osgeo.org/geos/geos-3.6.2.tar.bz2

## Proj.4
wget http://download.osgeo.org/proj/proj-4.9.3.tar.gz

## GDAL
wget http://download.osgeo.org/gdal/2.2.1/gdal-2.2.1.tar.gz

## JSON-C
yum install json-c-devel

postgis

テスト用に gis_test という名称でcreatedb しています。

$ wget http://download.osgeo.org/postgis/source/postgis-2.3.3.tar.gz
$ tar -xvf postgis-2.3.3.tar.gz
$ cd postgis-2.3.3
$ ./configure \
    --with-pgsql=/usr/local/pgsql/bin/pg_config \
    --with-pgconfig=/usr/local/pgsql/bin/pg_config

$ /usr/local/pgsql/bin/createdb -U postgres -E utf8 gis_test
$ /usr/local/pgsql/bin/createlang -U postgres plpgsql gis_test
$ /usr/local/pgsql/bin/psql -U postgres -d gis_test \
    -f /usr/local/pgsql/share/contrib/postgis-2.3/postgis.sql
$ /usr/local/pgsql/bin/psql -U postgres -d gis_test \
    -f /usr/local/pgsql/share/contrib/postgis-2.3/spatial_ref_sys.sql

mapserver

http://mapserver.org/installation/unix.html

Prerequisites

■libpng
$ wget ftp://ftp-osl.osuosl.org/pub/libpng/src/libpng16/libpng-1.6.32.tar.gz

■freetype
$ wget http://download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.gz

■curl
$ wget https://curl.haxx.se/download/curl-7.55.1.tar.gz

■gdal
$ wget http://download.osgeo.org/gdal/2.2.1/gdal-2.2.1.tar.gz
vi include/fcgio.h
#include <stdio.h>   #なにやらerorになったので行追加

■fastcgi
$ wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz

■cairo
$ yum install cairo-devel

■harfbuzz
$ yum install harfbuzz-devel

■FriBidi
$ http://fribidi.org/download/fribidi-0.19.7.tar.bz2

■glib*
# yum install glib*
# yum update kernel
# yum update

mapserver

$ wget http://download.osgeo.org/mapserver/mapserver-7.0.6.tar.gz
$ tar xvf mapserver-7.0.6.tar.gz
$ cd mapserver-7.0.6
$ mkdir build
$ cd build
The following options are enabled by default
(version 7.0: WITH_PROJ, WITH_WMS, WITH_FRIBIDI, WITH_HARFBUFF,
              WITH_ICONV, WITH_CAIRO, WITH_FCGI, WITH_GEOS,
          WITH_POSTGIS, WITH_GDAL, WITH_OGR, WITH_WFS,
          WITH_WCS, WITH_LIBXML2, WITH_GIF.)

mapserverのdocumentに上記のようなcmakeのコメントがあったので、 以降は次のように実施。

$ cmake -DCMAKE_PREFIX_PATH=/usr/local/pgsql \
      -DFRIBIDI_INCLUDE_DIR="/usr/include/glib-2.0;/usr/lib64/glib-2.0/include;/usr/local/include/fribidi"  ..
$ make
$ su
# make install

mapservやshp2imgがinstallされたことが分かります

$ ls -l /usr/local/bin
total 176100
-rwxr-xr-x  1 root root    13480 Sep  9 05:41 shptreevis
-rwxr-xr-x  1 root root    18648 Sep  9 05:41 sortshp
-rwxr-xr-x  1 root root    18256 Sep  9 05:41 tile4ms
-rwxr-xr-x  1 root root    18448 Sep  9 05:41 shp2img
-rwxr-xr-x  1 root root    13592 Sep  9 05:41 shptree
-rwxr-xr-x  1 root root    13448 Sep  9 05:41 shptreetst
-rwxr-xr-x  1 root root    14312 Sep  9 05:41 mapserv
-rwxr-xr-x  1 root root    13320 Sep  9 05:41 msencrypt
-rwxr-xr-x  1 root root    13208 Sep  9 05:41 scalebar
-rwxr-xr-x  1 root root    13200 Sep  9 05:41 legend