在麒麟Linux源码编译安装PostGIS

接着上一篇在麒麟linux上安装Postgresql12.5 ,我们来安装 PostGIS插件。

方案

因为 PostgreSQL不是通过 rpm包安装的,所以即便 PostGIS有现成的rpm包,也无法使用(需要引用 PG的包)。

所以,我们还是采用源码编译的方式。

下载PostGIS源码

我们选择的版本是3.0.5, 如果是不同版本,那么后面他所依赖的东西可能略有差别。

下载地址: http://postgis.net/stuff/postgis-3.0.5.tar.gz

编译过程

运行

./configure

报错

configure: error: could not find geos-config within the current path. 
You may need to try re-running configure with a --with-geosconfig parameter.

报差错原因是缺少 geos依赖, 那就安装geos

yum install geos geos-devel

再运行./configure发现报错

configure: error: could not find proj.h or proj_api.h - 
you may need to specify the directory of a PROJ installation using --with-projdir

报差错原因是缺少 proj依赖,那就安装

yum install proj proj-devel

再次运行,还报错:

configure: error: gdal-config not found. 
Use --without-raster or try --with-gdalconfig=<path to gdal-config>

这个报错是PostGIS需要gdal,关于gdalPostGIS用来操作栅格数据.
文档 中,gdal需要的版本是2+.

GDAL, version 2+ is required 3+ is preferred. This is required for raster support. http://trac.osgeo.org/gdal/wiki/DownloadSource.

gdal源码安装

首先肯定想到有没有现成的 gdal安装包,可惜没找到合适的,那还是源码安装吧。

经过我几次尝试,发现 2.0版本根本无法编译,而2.3,2.4版本需要 proj 6以上的版本,而我们上面安装的是proj 4版本,最终确定2.1.4版本是可以编译的。

下面是编译过程。

下载源码:http://download.osgeo.org/gdal/2.1.4/gdal214.zip

解压到某个路径下。

编译gdal源码,运行

make

这个过程持续了挺长时间,大约20分钟,最终成功后输出.

image

然后安装gdal,运行

make install

成功后输出如下,提示安装在 /usr/local/lib

image

接着PostGIS编译

再运行PostGISconfigure

运行成功,得到下面的信息:

PostGIS is now configured for aarch64-unknown-linux-gnu

-------------- Compiler Info -------------
C compiler:           gcc -std=gnu99 -g -O2 -fno-math-errno -fno-signed-zeros
CPPFLAGS:              -I/usr/include   -I/usr/include/libxml2    
SQL preprocessor:     /usr/bin/cpp -traditional-cpp -w -P

-------------- Additional Info -------------
Interrupt Tests:   DISABLED use: --with-interrupt-tests to enable

-------------- Dependencies --------------
GEOS config:          /usr/bin/geos-config
GEOS version:         3.6.1
GDAL config:          /usr/local/bin/gdal-config
GDAL version:         2.1.4
PostgreSQL config:    /usr/local/pgsql/bin/pg_config
PostgreSQL version:   PostgreSQL 12.5
PROJ4 version:        49
Libxml2 config:       /usr/bin/xml2-config
Libxml2 version:      2.9.10
JSON-C support:       no
protobuf support:     no
PCRE support:         yes
Perl:                 /usr/bin/perl
Wagyu:                no

--------------- Extensions ---------------
PostGIS Raster:                     enabled
PostGIS Topology:                   enabled
SFCGAL support:                     disabled
Address Standardizer support:       enabled

-------- Documentation Generation --------
xsltproc:             /usr/bin/xsltproc
xsl style sheets:     /usr/share/sgml/docbook/xsl-stylesheets
dblatex:              
convert:              
mathml2.dtd:          http://www.w3.org/Math/DTD/mathml2/mathml2.dtd

configure: WARNING:  --------- GEOS VERSION WARNING ------------
configure: WARNING:   You are building against GEOS 3.6.1.
configure: WARNING:
configure: WARNING:   To take advantage of _all_ the features of
configure: WARNING:   PostGIS, GEOS 3.7.0 or higher is required.
configure: WARNING:
configure: WARNING:   For _most_ features, GEOS 3.6.0 is enough.
configure: WARNING:
configure: WARNING:   We recommend GEOS 3.7.0 or higher
configure: WARNING:
configure: WARNING:   You can download the latest versions from
configure: WARNING:   http://geos.osgeo.org/
configure: WARNING:

发现检查没问题后,就基本上离成功不远了。

开始编译postgis源码,运行

make

几分钟后,编译成功,输出

image

然后运行安装命令

make install

安装很快。

验证

结束后,我们来验证下。

查看下版本,没问题。

image

建张表,做个简单的空间查询。

postgres=# create table testg ( id int, geom geometry );
CREATE TABLE
postgres=# insert into testg values (1, ST_GeomFromText('point(116 39)'));
INSERT 0 1
postgres=# select st_astext(geom) from testg where ST_Intersects(ST_GeomFromText('POLYGON((116 39, 116.1 39, 116.1 39.1, 116 39.1, 116 39))'), geom);
st_astext
---------------
POINT(116 39)
(1 row)
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值