PostgreSQL + Ludia + PostGIS な環境作り

MacPortsだと Ludia の環境が PostgreSQL 8.1 しか見つからず、PostGISは 8.2 or 8.3 しかありませんでした。
PostGISよりLudiaの方が手動でインストールするのが面倒だったので、Ludia を port install して PostGISの方は手動でインストールすることにしました。


PostgreSQL 8.1 + Ludia

インストール

sudo port install postgresql81-ludia

DBの領域作り

sudo mkdir -p /opt/local/var/db/postgresql81/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql81/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql81/bin/initdb -D /opt/local/var/db/postgresql81/defaultdb'

サーバ起動

sudo su postgres -c '/opt/local/lib/postgresql81/bin/pg_ctl -D /opt/local/var/db/postgresql81/defaultdb start'

データベースにLudia用の関数とか作成

psql81 -f /opt/local/share/postgresql81/pgsenna2.sql -U postgres project_development


PostGIS

インストール

wget http://postgis.refractions.net/download/postgis-1.3.6.tar.gz
tar zxvf postgis-1.3.6.tar.gz
cd postgis-1.3.6
./configure --with-pgsql=/opt/local/lib/postgresql81/bin/pg_config
make
sudo make install

PostGIS用の関数などをデータベースに定義

createlang plpgsql -U postgres project_development
psql81 -f /opt/local/share/lwpostgis.sql -U postgres project_development