postgresql和postgis外掛安裝

hotdog04發表於2015-11-24

#################################
一、postgresql安裝:
#################################
1、依賴包安裝:
依賴包檢查:
yum install  gcc perl-ExtUtils-Embed  readline-devel zlib-devel python-devel -y
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' \
perl-ExtUtils-Embed \
readline \
readline-devel \
zlib \
zlib-devel \
python-devel \
gcc \
libaio \
libaio-devel \
make \
gcc-c++ \
openssl \
openssl-devel \
sysstat | grep -i not

依賴包安裝:
yum install perl-ExtUtils-Embed readline readline-devel zlib zlib-devel python-devel gcc gcc-c++ libaio libaio-devel make sysstat openssl openssl-devel -y

2、編譯安裝postgresql:
cd /disk1/soft/postgresql-9.4.4
./configure --prefix=/usr/local/pgsql9.4.4 --with-perl --with-python --with-libxml --with-openssl --with-pam  --with-libxslt --with-segsize=4 --with-wal-segsize=64
make
make install

3、編譯安裝contrib:
cd /disk1/soft/postgresql-9.4.4/contrib
make all
make install


#################################
二、postgis安裝:
#################################
1、依賴包編譯安裝:
proj4:     proj.4-4.7.0
./configure --prefix=/usr/local/postgis
make
make install

GEOS:      geos-3.5.0
./configure --prefix=/usr/local/postgis
make
make install

 

LibXML2 : libxml2-2.9.2
./configure --prefix=/usr/local/postgis
make
make install


JSON-C  :  json-c-json-c-0.12
./configure --prefix=/usr/local/postgis
make
make install


GDAL:      gdal-2.0.0
./configure --prefix=/usr/local/postgis
make
make install

2、編譯安裝postgis:
./configure  --with-pgconfig=/usr/local/pgsql9.4.4/bin/pg_config

./configure  --with-pgconfig=/usr/local/pgsql9.4.4/bin/pg_config --with-gdalconfig=/usr/local/postgis/bin/gdal-config \
--with-geosconfig=/usr/local/postgis/bin/geos-config --with-xml2config=/usr/local/postgis/bin/xml2-config \
--with-projdir=/usr/local/postgis  --with-jsondir=/usr/local/postgis --with-libiconv=/usr/bin  \
--with-raster --with-topology --with-gettext=no
make
make install


#######################
三、資料庫例項安裝
#######################
1、新增動態連結庫:
echo "/usr/local/postgis/lib/" >> /etc/ld.so.conf
ldconfig

2、新增軟連線:
cd /usr/local
ln -s pgsql9.4.4 pgsql

 

3、新增環境變數:
su - postgres
vi .bash_profile
PATH=$PATH:$HOME/bin:/usr/local/pgsql/bin
LD_LIBRARY_PATH=/usr/local/pgsql/lib
export LD_LIBRARY_PATH

. .bash_profile

4、安裝啟動:
安裝:
initdb  -D /disk1/pg7001

修改配置檔案埠為7001:
vi postgresql.conf
port=7001
啟動:
pg_ctl -D /disk1/pg7001

5、登入測試postgis外掛是否正常:
psql -p 7001
postgres=# create database test;
CREATE DATABASE
postgres=# \c test;
You are now connected to database "test" as user "postgres".
test=# create extension postgis;
CREATE EXTENSION
檢視外掛安裝檢視:
select *from pg_available_extensions;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/20625855/viewspace-1845425/,如需轉載,請註明出處,否則將追究法律責任。

相關文章