跳转到主要内容

Anolis 8.9 编译安装 postgis 3.4.2

依赖安装

sudo yum install protobuf-devel protobuf-c-devel mpfr-devel json-c cmake gcc gcc-c++ sqlite sqlite-devel libtiff libtiff-devel
libcurl-devel boost-devel readline-devel libxml2-devel wget

需要源码编译的安装包

附件包含了安装包,或者自行下载

软件名 版本
proj 9.4
geos 3.12.2
gdal 3.8.5
sfcgal 5.6.1
postgresql 15.7
postgis 3.4.2

proj 9.4

wget https://download.osgeo.org/proj/proj-9.4.0.tar.gz

tar xvzf proj-9.4.0.tar.gz
cd proj-9.4.0
mkdir build && cd build
cmake ..
make -j 4
sudo make install

geos 3.12.2

wget https://download.osgeo.org/geos/geos-3.12.2.tar.bz2

tar xvjf geos-3.12.2.tar.bz2
cd geos-3.12.2
mkdir build && cd build
cmake ..
make -j 4
sudo make install

gdal 3.8.5

wget https://github.com/OSGeo/gdal/releases/download/v3.8.5/gdal-3.8.5.tar.gz

tar xvzf gdal-3.8.5.tar.gz
cd gdal-3.8.5
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j 4
sudo make install

cgal 5.6.1

wget https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.14.3/CGAL-4.14.3.tar.xz

tar xvJf CGAL-4.14.3.tar.xz
cd CGAL-4.14.3

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j 4
sudo make install

sfcgal 1.4

wget https://gitlab.com/sfcgal/SFCGAL/-/archive/v1.4.1/SFCGAL-v1.4.1.tar.gz

tar xvzf SFCGAL-v1.4.1.tar.gz
cd SFCGAL-v1.4.1
mkdir build && cd build
cmake ..
make -j 4
sudo make install

postgresql 15

wget https://ftp.postgresql.org/pub/source/v15.7/postgresql-15.7.tar.gz

tar xvzf postgresql-15.7.tar.gz
cd postgresql-15.7
./configure

make world -j4
sudo make install-world

postgis 3.4.2

wget https://download.osgeo.org/postgis/source/postgis-3.4.2.tar.gz

tar xvzf postgis-3.4.2.tar.gz
cd postgis-3.4.2


export PATH=/usr/local/pgsql/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/pgsql/lib:$LD_LIBRARY_PATH

wget -O build-aux/config.sub "git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD"
wget -O build-aux/config.guess "git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD"


./configure
make -j4
sudo make install

安装插件,检验 postgis 是否成功安装

sudo vim /etc/ld.so.conf

追加以下内容 到 /etc/ld.so.conf

/usr/local/lib64

更新缓存

sudo ldconfig -v

连接数据库,创建插件

psql -dpostgres

psql (15.7)
Type "help" for help.

postgres=# create extension postgis;
CREATE EXTENSION
postgres=# select postgis_full_version();
                                                                                                                                             postgis_full_version

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------
 POSTGIS="3.4.2 c19ce56" [EXTENSION] PGSQL="150" GEOS="3.12.2-CAPI-1.18.2" PROJ="9.4.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/home/loongson/.local/share/proj DATABASE_PATH=/usr/local/share/proj/proj
.db" LIBXML="2.9.7" LIBPROTOBUF="1.3.0" WAGYU="0.5.0 (Internal)"
(1 row)