本次安装会安装如下软件(包含版本号):
| 工具 | 版本 | 描述 |
|---|---|---|
| postgresql | postgresql-10.7 | postgresql数据库 |
| proj | proj-6.2.1 | PROJ框架在做投影,坐标系转换时,其操作风格类似于Linux Shell命令。 |
| geos | geos-3.8. | GEOS的前身是JTS,JTS提供了全功能的,强大的空间操作和空间判断。 |
| libxml | libxml2-2.9 | libxml是一个用于解析xml文件的库,在各个平台下都能使用,也支持多种语言 |
| json-c | json-c-0.13.1-20180305 | JSON-C实现了一个引用计数对象模型,它允许您轻松地使用C语言来构建JSON对象,将它们输出为JSON格式的字符串,并将JSON格式字符串解析回JSON对象的C语言表示形式。 |
| gdal | gdal-3.1.2 | GDAL(Geospatial Data Abstraction Library)是一个在X/MIT许可协议下的开源栅格空间数据转换库。 |
| boost-devel | boost-devel.x86_64 | |
| cgal | cgal-4.14.3 | CGAL是Computational Geometry Algorithms Library(计算几何算法库)的缩写,用C++语言提供高效、可靠的算法库。 |
| SFCGAL | SFCGAL-1.3.8 | |
| postgis | postgis-3.0.2 | postgis软件 |
postgresql下载地址
postgresql软件安装 创建用户和用户组# 创建用户组 groupadd postgres # 创建用户 useradd -g postgres -d /home/postgres postgres安装依赖库
# 安装zlib [root@surpass postgissoft]# yum search zlib|grep devel zlib-devel.i686 : Header files and libraries for Zlib development zlib-devel.x86_64 : Header files and libraries for Zlib development zlib-static.i686 : Static libraries for Zlib development zlib-static.x86_64 : Static libraries for Zlib development [root@surpass postgissoft]# yum -y install zlib-devel.x86_64 # 安装readline [root@surpass postgissoft]# yum search readline|grep devel readline-devel.i686 : Files needed to develop programs which use the readline readline-devel.x86_64 : Files needed to develop programs which use the readline [root@surpass postgissoft]# yum -y install readline-devel.x86_64 # 安装gcc [root@surpass postgissoft]# yum install -y gcc
yum -y install zlib-devel.x86_64 yum -y install readline-devel.x86_64 yum install -y gcc编译安装
./configure --prefix=/usr/local/postgis
make && make install安装contrib工具
cd contrib/ make && make install配置环境变量
修改/ect/profile配置文件,在文件末尾追加如下内容
export PATH=/usr/local/postgis/bin:$PATH export LD_LIBRARY_PATH=/usr/local/postgis/lib:$LD_LIBRARY_PATH export PGDATA=/data/postgis/data
使配置文件生效
source /etc/profile创建数据库目录
mkdir -p /data/postgis/data chown -R postgres:postgres /data/初始化数据库
su postgres initdb修改配置文件
-
在pg_hba.conf配置文件里追加如下内容,允许远程服务器访问。
host all all 0.0.0.0/0 md5
-
在postgresql.conf文件中修改如下内容
listen_addresses = '*'
pg_ctl start创建用户和用户组
# 创建用户组 groupadd postgres # 创建用户 useradd -g postgres -d /home/postgres postgresPostgis安装 proj安装 安装依赖工具
yum install -y gcc gcc-c++ yum -y install sqlite-devel编译安装
./configure --prefix=/usr/local/proj-6.2.1
make && make install查看是否安装成功
cd /usr/local/proj-6.2.1/bin [root@surpass bin]# ls cct cs2cs geod gie invgeod invproj proj projinfogeos安装 geos解压
geos安装包是bz2格式的,解压需要安装如下软件:
yum -y install bzip2 tar -jxvf geos-3.8.1.tar.bz2安装cmake
cmake版本需要3.18.3
-
安装cmake依赖
yum -y install openssl-devel
-
安装cmake
./bootstrap gmake gmake install
-
查看cmake版本
[root@surpass cmake-3.18.2]# cmake --version cmake version 3.18.2
mkdir build cd build/ cmake CMAKE_INSTALL_PREFIX=/usr/local/geos-3.8.1 ..编译并且安装
make make install安装libxml2 安装依赖
yum -y install python-devel配置安装
./configure --prefix=/usr/local/libxml2-2.9.9编译并且安装
make make install安装json-c 配置安装
./configure --prefix=/usr/local/json-c-0.13.1编译并且安装
make make check make install安装gdal 配置安装
./configure --prefix=/usr/local/gdal-3.1.2 --with-proj=/usr/local/proj-6.2.1编译并且安装
make clean make make install查看gdal安装位置
/usr/local/gdal-3.1.2安装SFCGAL
由于SFCGAL需要依赖Boost、CGAL、GMP、MPFR这四个软件,所以具体总共需要先安装 以下四个软件:
- boost-devel.x86_64
- gmp-devel.x86_64
- mpfr-devel.x86_64
- CGAL-4.13.1
yum -y install boost-devel.x86_64安装gmp-devel.x86_64
yum -y install gmp-devel安装mpfr-devel.x86_64
yum -y install mpfr-devel安装cgal
-
在cgal-4.14.3下创建一个build文件夹。
mkdir build cd build
-
生成makefile
cmake CMAKE_INSTALL_PREFIX=/usr/local/cgal-4.14.3 ..
-
编译并且安装
make make install
-
在SFCGAL-1.3.8下创建一个build文件夹。
mkdir build cd build
-
生成makefile
cmake CMAKE_INSTALL_PREFIX=/usr/local/SFCGAL-1.3.8 ..
-
编译并且安装
make make install
-
配置安装
./configure --prefix=/usr/local/postgis-3.0.2 --with-gdalconfig=/usr/local/gdal-3.1.2/bin/gdal-config --with-pgconfig=/usr/local/postgis/bin/pg_config --with-geosconfig=/usr/local/bin/geos-config --with-projdir=/usr/local/proj-6.2.1 --with-xml2config=/usr/local/libxml2-2.9.9/bin/xml2-config --with-jsondir=/usr/local/json-c-0.13.1 --with-sfcgal=/home/postgres/postgissoft/SFCGAL/SFCGAL-1.3.8/build/sfcgal-config
-
编译并且安装
make make install
编辑文件/etc/ld.so.conf,在文件尾部追加如下内容:
/usr/local/proj-6.2.1/lib /usr/local/postgis/lib /usr/local/lib /usr/local/lib /usr/local/libxml2-2.9.9/lib /usr/local/json-c-0.13.1/lib /usr/local/lib64
加载动态库到内存
ldconfig在数据库中创建插件
create database test; c test; create extension postgis;查看postgis版本
test=# select postgis_full_version();
postgis_full_version
------------------------------------------------------------------------------------------------------------
-----------
POSTGIS="3.0.2 2fb2a18" [EXTENSION] PGSQL="100" GEOS="3.8.1-CAPI-1.13.3" PROJ="6.2.1" LIBXML="2.9.9" LIBJSO
N="0.13.1"



