内容概述
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;
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。