CentOS5.3にPostGISをインストールする。
PostgreSQLがインストールされていることが前提です。
インストール手順は前回の記事を参照
GCCなどのコンパイラが無い場合はyumでインストールします。
yum search gcc-c++ yum install gcc-c++
まずはPROJをインストールします。
PROJをダウンロードし、解凍します。
wget http://download.osgeo.org/proj/proj-4.6.1.tar.gz tar xvfz proj-4.6.1.tar.gz
解凍したproj-4.6.1のコンパイルとインストールです。
cd /root/proj-4.6.1 ./configure make make install
次にGEOSをインストールします。
GEOSをダウンロードして解凍します。
wget http://download.osgeo.org/geos/geos-3.1.1.tar.bz2 tar -jxvf geos-3.1.1.tar.bz2
解凍したgeos-3.1.1のコンパイルとインストールです。
cd /root/geos-3.1.1 ./configure make make install
やっとメインのPostGISをインストールします。
先にPostgreSQLを停止します。
service postgresql stop
PostGISをダウンロードして解凍します。
wget http://www.postgis.org/download/postgis-1.4.0.tar.gz tar xvfz postgis-1.4.0.tar.gz
解凍したpostgis-1.4.0のコンパイルとインストールです。
cd /root/postgis-1.4.0 ./configure make make install
次に設定です。
PROJとGEOSのライブラリを /etc/ld.so.conf に登録します。
/etc/ld.so.conf
include ld.so.fonf.d/*.conf /usr/local/lib
登録したライブラリを有効にします。
ldconfig
最後にデータベースの作成方法です。
PostgreSQLのサービスを開始します
service postgresql start
とりあえず以下のようなデータベースを作成します。
createdb -EUTF-8 -Upostgres template_postgis
上で作成したデータベースにPL/pgSQLを有効にし、PostGISの関数等を組み込みます。
createlang plpgsql template_postgis psql -Upostgres -f /usr/share/pgsql/contrib/postgis.sql template_postgis psql -Upostgres -f /usr/share/pgsql/contrib/spatial_ref_sys.sql template_postgis
これでPostGISの利用が可能となりました。
毎回 PL/pgSQL、 postgis.sql 、 spatial_ref_sys.sql を取り込むのはめんどくさいので、PostGISを利用するデータベースには上記で作成した template_postgis を読み込むようにします。
createdb -EUTF-8 -Upostgres -Ttemplate_postgis Sample
操作については以前の記事等を参考にしてください