環(huán)境
? ? ?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
移動解壓數(shù)據(jù)到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
注意:
?后續(xù)針對所有使用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
?注意:
后續(xù)在編譯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'
所以安裝時候需要設(shè)置一個宏 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-3.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 這里對應(yīng)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數(shù)據(jù))
????https://github.com/CGAL/cgal/releases?page=4
????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數(shù)據(jù)庫
\c mytest
創(chuàng)建數(shù)據(jù)庫中postgis插件
CREATE EXTENSION postgis;
查看版本
SELECT postgis_full_version();

創(chuàng)建sfcgal插件:
create extension postgis_sfcgal;
到此postgis安裝成功