共计 2463 个字符,预计需要花费 7 分钟才能阅读完成。
内容概述
PG14 装置 postgis 3.2.1 为例子,centos 7.9 下
postgis 是独立发行的 pg extension,它依赖于一系列的包,须要独自装置。本文只笼罩起码依赖,有些高级性能依赖的包如 SFCGAL 等没有波及。
有的依赖包零碎可能曾经装置过了,能够相应的确认版本是否满足要求
yum list |grep geos
yum list installed |grep geos
yum remove geos
选项 1:通过 yum 装置依赖包
# > 0.9
sudo yum install json-c
# > 2.5
sudo yum install libxml2
# > 4.9
sudo yum install proj
# > 3.6
sudo yum install geos
# > 2
sudo yum install gdal
选项 1:通过源码编译装置依赖包
centos 装置源版本比拟老,可能不满足要求,须要源码编译装置
mkdir -p /usr/local/libpostgis
sqlite3
sqlite-autoconf-3380400/
./configure --prefix=/usr/local/libpostgis/sqlite3
make
make install
mv /usr/bin/sqlite3 /usr/bin/sqlite3_old
ln -s /usr/local/libpostgis/sqlite3/bin/sqlite3 /usr/bin/sqlite3
ll /usr/bin/sqlite3
echo "/usr/local/libpostgis/sqlite3/lib" > /etc/ld.so.conf.d/sqlite3.conf
ll /usr/local/libpostgis/sqlite3/
ldconfig
sqlite3 --version
export PKG_CONFIG_PATH=/usr/local/libpostgis/sqlite3/lib/pkgconfig:$PKG_CONFIG_PATH
proj
./configure --prefix=/usr/local/libpostgis/proj
make && make install
echo "/usr/local/libpostgis/proj/lib" > /etc/ld.so.conf.d/proj-6.3.1.conf
ldconfig
export PKG_CONFIG_PATH=/usr/local/libpostgis/proj/lib/pkgconfig:$PKG_CONFIG_PATH
geos
./configure --prefix=/usr/local/libpostgis/geos
make && make install
echo "/usr/local/libpostgis/geos/lib" > /etc/ld.so.conf.d/geos-3.8.0.conf
ldconfig
gdal
./configure --prefix=/usr/local/libpostgis/gdal --with-proj=/usr/local/libpostgis/proj
make && make install
echo "/usr/local/libpostgis/gdal/lib" > /etc/ld.so.conf.d/gdal-3.4.3.conf
ldconfig
protobuf
./autogen.sh --prefix=/usr/local/libpostgis/protobuf
./configure --prefix=/usr/local/libpostgis/protobuf
make && make install
echo "/usr/local/libpostgis/protobuf/lib" > /etc/ld.so.conf.d/protobuf-3.20.1.conf
ldconfig
export PKG_CONFIG_PATH=/usr/local/libpostgis/protobuf/lib/pkgconfig:$PKG_CONFIG_PATH
protobuf-c
./autogen.sh --prefix=/usr/local/libpostgis/protobuf-c
./configure --prefix=/usr/local/libpostgis/protobuf-c
make && make install
echo "/usr/local/libpostgis/protobuf-c/lib" > /etc/ld.so.conf.d/protobuf-c-1.4.0.conf
ldconfig
export PKG_CONFIG_PATH=/usr/local/libpostgis/protobuf/lib/pkgconfig:$PKG_CONFIG_PATH
源码编译装置 pg 数据库
./configure
make && make install
initdb -D DTAT_DIR
pg_ctl -D DTAT_DIR start
// 如果 pg 是源码编译装置的,须要指定 –prefix 为 pg 的 install 目录,以及相应的 pgconfig
// geosgdal 等为源码编译装置的,须要指定 geosconfig、gdalconfig
./configure --prefix=/home/work/pg/install --with-pgconfig=/home/work/pg/install/bin/pg_config --with-geosconfig=/usr/local/libpostgis/geos/bin/geos-config --with-gdalconfig=/usr/local/libpostgis/gdal/bin/gdal-config
make && make install
启动 pg,装置 postgis
psql -p 5980
postgre=# create extension postgis;
参考资料
postgis install – 内含各依赖包的地址
正文完