####安装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
#安装contrib目录下的一些工具,是第三方组织的一些工具代码,建议安装
cd contrib
make && make install
#初始化数据库
initdb -D /data/postgresql/data
#启动服务
pg_ctl -D /data/postgresql/data -l /var/postgresql/logfile start
####安装Proj4
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
ldconfig
###安装GEOS
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
ldconfig
###安装GDAL
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;