postgreSQL插件
# pg12 yum安装postgis
Centos
安装repo源:
rpm -ivh https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
安装包(postgis30_12):
yum install postgis30_12.x86_64 postgis30_12-client.x86_64 postgis30_12-debuginfo.x86_64 postgis30_12-devel.x86_64 postgis30_12-docs.x86_64 postgis30_12-gui.x86_64 postgis30_12-utils.x86_64
ubuntu22.04
cp -a /etc/apt/sources.list{,.bak}
cat >/etc/apt/sources.list<<'EOF'
deb http://security.ubuntu.com/ubuntu/ jammy main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
EOF
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
apt update -y
apt install -y postgresql-12 postgresql-client-12 postgresql-common postgresql-common-dev
apt install -y postgis postgresql-12-postgis-3
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 登录数据库:
创建:CREATE EXTENSION postgis;
检查:SELECT PostGIS_version();
# 麒麟系统编译安装postgis-2.5.6
- 系统信息
cmake version 3.12.1
- 安装需要依赖库
#Centos 服务器系统
yum install libcurl-devel curl openssl-devel -y
#Ubuntu 麒麟桌面系统
apt-get install libcurl4-openssl-dev openssl-dev
#欧拉22.03 (LTS-SP4)
yum install -y cmake readline-devel zlib-devel openssl-devel libxml2-devel libxslt-devel sqlite-devel libtiff-devel proj-devel geos-devel json-c-devel protobuf-devel protobuf-c-devel # gcc gcc-c++ make
2
3
4
5
6
7
8
9
10
- Kylin Linux Advanced Server
#这三个是必须的
https://github.com/libgeos/geos/tags
https://github.com/OSGeo/gdal/tags
https://github.com/OSGeo/PROJ/tags
https://github.com/protobuf-c/protobuf-c/tags
https://github.com/json-c/json-c/tags
http://xmlsoft.org/downloads.html
https://gitlab.com/Oslandia/SFCGAL/-/releases
2
3
4
5
6
7
8
9
10
#必须
wget https://download.osgeo.org/postgis/source/postgis-2.5.6.tar.gz
wget https://github.com/OSGeo/gdal/archive/refs/tags/v3.5.0.tar.gz
wget https://github.com/libgeos/geos/archive/refs/tags/3.8.2.tar.gz
wget https://github.com/OSGeo/PROJ/archive/refs/tags/7.2.0.tar.gz
wget https://github.com/google/googletest/archive/release-1.8.1.zip
#看需求
wget https://gitlab.com/Oslandia/SFCGAL/-/archive/v1.3.7/SFCGAL-v1.3.7.tar.gz
wget https://github.com/protobuf-c/protobuf-c/archive/refs/tags/v1.4.0.tar.gz
wget https://github.com/json-c/json-c/archive/refs/tags/json-c-0.15-20200726.tar.gz
2
3
4
5
6
7
8
9
10
11
postgis版本不建议用太高,需要的make版本会要求更高c
# geos-3.8.2 (必须安装)
libgeos-geos3.8.2.tar.gz: wget https://github.com/libgeos/geos/archive/refs/tags/3.8.2.tar.gz
tar xf libgeos-geos3.8.2.tar.gz
cd geos-3.8.2/
mkdir build
cd build/
cmake ../
echo $?
make -j $(nproc)
make install
echo $?
2
3
4
5
6
7
8
9
# PROJ-7.2.0 (必须安装)
OSGeo-PROJ7.2.0.tar.gz: wget https://github.com/OSGeo/PROJ/archive/refs/tags/7.2.0.tar.gz
PROJ依赖包: wget https://github.com/google/googletest/archive/release-1.8.1.zip
tar xf OSGeo-PROJ7.2.0.tar.gz
cd PROJ-7.2.0/
mkdir -p build/googletest-download/googletest-prefix/src
cd build/
#上传包release-1.8.1.zip
mv release-1.8.1.zip /opt/soft/PROJ-7.2.0/build/googletest-download/googletest-prefix/src/release-1.8.1.zip
cd build/
cmake ../
echo $?
make -j $(nproc)
make install
echo $?
2
3
4
5
6
7
8
9
10
11
12
# gdal-3.5.0 (必须安装)
OSGeo-gdalv3.5.0.tar.gz: wget https://github.com/OSGeo/gdal/archive/refs/tags/v3.5.0.tar.gz
tar xf OSGeo-gdalv3.5.0.tar.gz
cd gdal-3.5.0/
ll
mkdir build
cd build/
cmake ../
make -j $(nproc)
make install
echo $?
2
3
4
5
6
7
8
9
# 编译postgis-2.5.6
find / -name pg_config
,先找一下pg_config在哪里
ln -s /opt/postgresql/lib/libpq.so.5.12 /usr/local/lib/libpq.so.5
tar xf postgis-2.5.6.tar.gz
cd postgis-2.5.6
./configure --prefix=/usr/local/postgis --with-pgconfig=/opt/postgresql/bin/pg_config
make -j $(nproc)
make install
echo $?
2
3
4
5
6
7
8
# 使用ldd查看postgis-2.5.so,创建软链接
使用ldd命令查看,如果有“not found”,查找该so文件,添加软链接,如果找不到对应的so,那就是上面编译有问题
ldd /opt/postgresql/lib/postgis-2.5.so
ldd /opt/postgresql/lib/rtpostgis-2.5.so
ln -s /usr/local/lib64/libproj.so.19 /lib64/libproj.so.19
ln -s /usr/local/lib/libgeos_c.so.1 /lib64/libgeos_c.so.1
ln -s /usr/local/lib/libgeos.so.3.8.2 /lib64/libgeos.so.3.8.2
ln -s /usr/local/lib64/libgdal.so.31 /lib64/libgdal.so.31
ln -s /usr/local/lib/libproj.so.12.0.0 /usr/lib64/libproj.so.12 #在
2
3
4
5
6
# 创建postgis,检查
CREATE EXTENSION postgis;
COMMENT ON EXTENSION postgis IS 'PostGIS geometry, geography, and raster spatial types and functions';
2
3
# 欧拉操作系统(22.03 (LTS-SP4))安装postgis-2.5.6
- 安装基础依赖包
yum install -y cmake readline-devel zlib-devel openssl-devel libxml2-devel libxslt-devel sqlite-devel libtiff-devel proj-devel geos-devel json-c-devel protobuf-devel protobuf-c-devel # gcc gcc-c++ make
编译步骤和上面的基本差不多,只有在编译postgis的时候有点区别
# 编译postgis-2.5.6
./configure \
--with-pgconfig=/opt/postgresql/bin/pg_config \
--with-geosconfig=/usr/local/bin/geos-config \
--with-projdir=/opt/soft/PROJ-7.2.0/build \
--with-gdalconfig=/usr/local/bin/gdal-config
2
3
4
5
- 添加软链接
ln -s /usr/local/lib64/libproj.so.19 /usr/lib64/libproj.so.19
ln -s /usr/local/lib64/libgdal.so.31 /usr/lib64/libgdal.so.31
2
# 个人存储下载地址。。。
#yum包
postgis-12.14.zip
源码安装包
postgresql12.10-postgis2.5.6.zip
2
3
4
5
6
- 01
- libblockdev库本地提权漏洞(CVE-2025-6019)08-08
- 02
- postgreSQL通过keepalived配置主从自动切换06-30
- 03
- ubuntu2204编译安装php7.4.3306-30