Centos7.5下PostgreSQL15中安装Postgis3.3.0
环境postgresql 15 centos7.5
安装
1.下载postgis-3.3.0.tar.gz
http://download.osgeo.org/postgis/source/
解压:
tar -zxvf postgis-3.3.0.tar.gz
移动解压数据到opt目录下
mv postgis-3.3.0 /opt/
2.依赖项
yum安装依赖项
yum install libxml2-devel.x86_64
yum install ncurses-devel
yum install openssl-devel
cmake 3.3.2:
https://cmake.org/files/v3.23/cmake-3.23.1.tar.gz
tar -zxvfcmake-3.23.1.tar.gz
cd cmake-3.3.2
./configure
make && make install
注意:
后续针对所有使用cmake 安装的依赖我们必须要在CMakeLists.txt 中添加 add_compile_options(-fPIC),不然后边会有一些报错信息
sqlit3 3.4:
https://www.sqlite.org/2021/sqlite-autoconf-3350500.tar.gz
tar -zxvf sqlite-autoconf-3400000.tar.gz
cd sqlite-autoconf-3400000
./configure
make && make install
查看版本 usr/local/bin/sqlite3 --version
注意:
后续在编译gdal时候有使用报错信息如下:
/root/gdal-2.3.0/.libs/libgdal.so: undefined reference to sqlite3_column_origin_name'
/root/gdal-2.3.0/.libs/libgdal.so: undefined reference to sqlite3_column_table_name'
所以安装时候需要设置一个宏 https://www.sqlite.org/compile.html 具体做法是在
sqlite3.c中添加一行 #define SQLITE_ENABLE_COLUMN_METADATA 1
geos3.9.3:
https://download.osgeo.org/geos
下载geos-3.9.tar.bz2
tar -jxvf geos-.9.tar.bz2
./configure
make && make install
PROJ 6.1.1:
http://download.osgeo.org/proj
proj-6.1.1.tar.gz
tar -jxvf proj-6.1.1.tar.gz
./configure
make && make install
protobuf:(这里使用的是3.2.0 版本)
https://github.com/protocolbuffers/protobuf/releases?page=12
protobuf-3.2.0.tar.gz
tar -zxvf protobuf-3.2.0.tar.gz
cd cmake
cmake .
make
make install
查看版本:protoc --version
默认是安装在 /usr/local/bin/protoc 我们拷贝一份到 /usr/bin 目录下
cp /usr/local/bin/protoc usr/bin/protoc
protobuf-c(protobuf-c-1.1.0 这里对应protobuf版本为 3.2.0):
https://github.com/protobuf-c/protobuf-c/releases?page=1
tar protobuf-c-1.1.0.tar.gz
cd build-cmake
cmake .
make && make install
GDAL3.3(make时间很长)
https://download.osgeo.org/gdal/3.3.0/
tar -zxvf gdal-3.3.0.tar.gz
cd gdal-3.3.0
./configure
make && make install
json-c 0.13:
https://github.com/json-c/json-c/tags
json-c-json-c-0.13.1-20180305.tar.gz
cd json-c-json-c-0.13.1-20180305
./configure
make && make install
安装CGAL 4.14(非必须,如果要装SFCGAL) (处理3D数据)
https://github.com/CGAL/cgal/releases?page=4
CGAL存在一些系统依赖库必须要安装
yum -y install gmp-devel boost-devel mpfr-devel zlib-devel libxml2-devel
CGAL-4.14.tar.xz
tar -xvJf CGAL-4.14.tar.xz
cd CGAL-4.14
mkdir build
cd build
cmake ..
make
make install
SFCGALv1.3.7
https://github.com/Oslandia/SFCGAL/releases
tar -zxvf SFCGAL-1.3.7.tar.gz
cd SFCGAL-1.3.7
mkdir build
cd build
cmake ..
make
make install
3.安装postgis(必须使用 postgre用户进行安装)
确定之前安装的pg的配置文件pg_config (pg 安装bin目录下),我的是/opt/pgsql/bin/pg_config
cd /opt/postgis-3.3.2
./configure --with-pgconfig=/opt/pgsql/bin/pg_config
./configure --with-pgconfig=/opt/pgsql/bin/pg_config
make
make install
错误:gcc: error: /usr/local/lib/libSFCGAL.so: No such file or directory
libSFCGAL.so 在/usr/local/lib64目录下,将其拷贝到上面目录即可 或者建立软连接
ln -sv /usr/local/lib64/libSFCGAL.so.1.3.7/usr/local/lib/libSFCGAL.so
ln -sv /usr/local/lib64/libSFCGAL.so.1.3.7/usr/local/lib/libSFCGAL.so.1
4、测试
进入mytest数据库
\c mytest
创建数据库中postgis插件
CREATE EXTENSION postgis;
查看版本
SELECT postgis_full_version();
创建sfcgal插件:
create extension postgis_sfcgal;
到此postgis安装成功
页:
[1]