####安裝Postgresql-11
yum install zlib-devel gcc make
groupadd postgres
useradd -g postgres postgres
passwd postgres
mkdir -p /usr/local/postgresql
chown -R postgres:postgres /usr/local/postgresql
cd /usr/local/src/
wget https://ftp.postgresql.org/pub/source/v11.3/postgresql-11.3.tar.gz
tar -xzvf postgresql-11.3.tar.gz
cd postgresql-11.3
./configure --prefix=/usr/local/postgresql --without-readline
make && make install
sql
#安裝contrib目錄下的一些工具,是第三方組織的一些工具代碼,建議安裝
cd contrib
make && make install數據庫
#初始化數據庫
initdb -D /data/postgresql/data工具
#啓動服務
pg_ctl -D /data/postgresql/data -l /var/postgresql/logfile startpost
####安裝Proj4postgresql
wget http://download.osgeo.org/proj/proj-4.9.3.tar.gz
tar -xf proj-4.9.3.tar.gz
cd proj-4.9.3
./configure --prefix=/usr/local/pgsql/plugin/proj
make
make install
echo "/usr/local/pgsql/plugin/proj/lib" > /etc/ld.so.conf.d/proj-4.9.3.conf
ldconfigcode
###安裝GEOSblog
wget http://download.osgeo.org/geos/geos-3.6.1.tar.bz2
tar -jxf geos-3.6.1.tar.bz2
cd geos-3.6.1
./configure --prefix=/usr/local/pgsql/plugin/geos
make
make install
echo "/usr/local/pgsql/plugin/geos/lib" > /etc/ld.so.conf.d/geos-3.6.1.conf
ldconfigget
###安裝GDALit
wget http://download.osgeo.org/gdal/2.1.2/gdal-2.1.2.tar.gz
tar -xf gdal-2.1.2.tar.gz
cd gdal-2.1.2
./configure --prefix=/usr/local/pgsql/plugin/gdal
make
make install
echo "/usr/local/pgsql/plugin/gdal/lib" > /etc/ld.so.conf.d/gdal-2.1.2.conf
ldconfig登錄
###安裝PostGIS
wget https://download.osgeo.org/postgis/source/postgis-2.5.2.tar.gz
tar -xvzf postgis-2.5.2.tar.gz
cd postgis-2.5.2
./configure --prefix=/usr/local/pgsql/plugin/postgis --with-pgconfig=/usr/local/postgresql/bin/pg_config --with-geosconfig=/usr/local/pgsql/plugin/geos/bin/geos-config --with-gdalconfig=/usr/local/pgsql/plugin/gdal/bin/gdal-config --with-projdir=/usr/local/pgsql/plugin/proj
make
make install
###安裝fuzzystrmatch
cd /usr/local/src/postgresql-11.3/contrib/fuzzystrmatch
make && make install
###檢查PostGiS是否安裝成功
#切換postgres用戶
su - postgres
#登陸PG數據庫
psql
# 建立一個數據庫
create database postgis;
#切換到postgis庫中
\c postgis
#顯示一下擴展模塊
\dx
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
CREATE EXTENSION fuzzystrmatch;
CREATE EXTENSION postgis_tiger_geocoder;