安装PostGIS-2.1.8
admin
2023-05-21 20:02:36
0

版本:

proj-4.8.0.tar.gz

geos-3.4.2.tar.bz2

gdal-2.0.1.tar.gz

PostGIS-2.1.82.1.8


前提条件:

安装PostGIS之前必须先安装proj,geos,gdal.


安装proj4

[root@Darren2 tools]# wget http://download.osgeo.org/proj/proj-4.8.0.tar.gz

[root@Darren2 tools]# tar xf proj-4.8.0.tar.gz

[root@Darren2 tools]# cd proj-4.8.0

[root@Darren2 proj-4.8.0]# ./configure --prefix=/usr/local/pgsql/plugin/proj

[root@Darren2 proj-4.8.0]# make && make install

Waiting for about 1min


#配置和加载动态链接库:

[root@Darren2 proj-4.8.0]# vim /etc/ld.so.conf.d/proj-4.8.0.conf

/usr/local/pgsql/plugin/proj/lib

[root@Darren2 proj-4.8.0]# ldconfig


安装geos

[root@Darren2 tools]# wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2

[root@Darren2 tools]# bzip2 -d geos-3.4.2.tar.bz2

[root@Darren2 tools]# tar xf geos-3.4.2.tar

[root@Darren2 geos-3.4.2]# ./configure --prefix=/usr/local/pgsql/plugin/geos

......

Swig: false

Python bindings: false

Ruby bindings: false

PHP bindings: false

#这些可忽略


[root@Darren2 geos-3.4.2]# make && make install

Waiting for about 5min


#配置和加载动态链接库:

[root@Darren2 geos-3.4.2]# vim /etc/ld.so.conf.d/geos-3.4.2.conf

/usr/local/pgsql/plugin/geos/lib

[root@Darren2 geos-3.4.2]# ldconfig


安装gdal

[root@Darren2 tools]# wget http://download.osgeo.org/gdal/2.0.1/gdal-2.0.1.tar.gz

[root@Darren2 tools]# tar xf gdal-2.0.1.tar.gz

[root@Darren2 tools]# cd gdal-2.0.1

[root@Darren2 gdal-2.0.1]# ./configure --prefix=/usr/local/pgsql/plugin/gdal

[root@Darren2 gdal-2.0.1]#make && make install

Waiting for about 15min


#配置和加载动态链接库:

[root@Darren2 gdal-2.0.1]# vim /etc/ld.so.conf.d/gdal-2.0.1.conf

/usr/local/pgsql/plugin/gdal/lib

[root@Darren2 gdal-2.0.1]# ldconfig


安装PostGIS

[root@Darren2 tools]# wget http://download.osgeo.org/postgis/source/postgis-2.1.8.tar.gz

[root@Darren2 tools]# tar xf postgis-2.1.8.tar.gz

./configure --help参数:

  --prefix=PREFIX         install architecture-independent files in PREFIX [/usr/local]

  --with-pgconfig=FILE    specify an alternative pg_config file

  --with-geosconfig=FILE  specify an alternative geos-config file

  --with-projdir=PATH     specify the PROJ.4 installation directory

  --without-raster        Disable the raster extension


[root@Darren2 postgis-2.1.8]# ./configure --prefix=/usr/local/pgsql/plugin/postgis \

--with-pgconfig=/usr/local/pgsql/bin/pg_config \

--with-geosconfig=/usr/local/pgsql/plugin/geos/bin/geos-config \

--with-gdalconfig=/usr/local/pgsql/plugin/gdal/bin/gdal-config \

--with-projdir=/usr/local/pgsql/plugin/proj

.........

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

 -------------- Compiler Info -------------

  C compiler:           gcc -g -O2

  C++ compiler:         g++ -g -O2

  SQL preprocessor:     /usr/bin/cpp -w -traditional-cpp -P

 -------------- Dependencies --------------

  GEOS config:          /opt/geos-3.4.2/bin/geos-config

  GEOS version:         3.4.2

  GDAL config:          /usr/local/bin/gdal-config

  GDAL version:         2.0.1

  PostgreSQL config:    /usr/local/pgsql/bin/pg_config

  PostgreSQL version:   PostgreSQL 9.6.3

  PROJ4 version:        48

  Libxml2 config:       /usr/bin/xml2-config

  Libxml2 version:      2.7.6

  JSON-C support:       no

  PostGIS debug level:  0

  Perl:                 /usr/bin/perl

 --------------- Extensions ---------------

  PostGIS Raster:       enabled

  PostGIS Topology:     enabled

  SFCGAL support:       disabled

 -------- Documentation Generation --------

  xsltproc:             

  xsl style sheets:     

  dblatex:             

  convert:             

  mathml2.dtd:          http://www.w3.org/Math/DTD/mathml2/mathml2.dtd


#编译

[root@Darren2 postgis-2.1.8]# make

......

PostGIS was built successfully. Ready to install.

[root@Darren2 postgis-2.1.8]# make install

......

make[2]: Leaving directory `/home/tools/postgis-2.1.8/extensions/postgis_topology'

make[1]: Leaving directory `/home/tools/postgis-2.1.8/extensions'

Wait for about 1min


检查PostGIS是否安装成功

Darren2:postgres:/usr/local/pgsql:>psql

postgres=# select * from pg_available_extensions where name like 'postgis%';

          name          | default_version | installed_version |                               comment                               

------------------------+-----------------+-------------------+---------------------------------------------------------------------

 postgis                | 2.1.8           |                   | PostGIS geometry, geography, and raster spatial types and functions

 postgis_tiger_geocoder | 2.1.8           |                   | PostGIS tiger geocoder and reverse geocoder

 postgis_topology       | 2.1.8           |                   | PostGIS topology spatial types and functions

postgres=# create extension postgis;

postgres=# create extension postgis_topology;

postgres=# create extension fuzzystrmatch;

postgres=# create extension postgis_tiger_geocoder;

postgres=# \dx

                                            List of installed extensions

          Name          | Version |   Schema   |                             Description                             

------------------------+---------+------------+---------------------------------------------------------------------

fuzzystrmatch          | 1.1     | public     | determine similarities and distance between strings

plpgsql                | 1.0     | pg_catalog | PL/pgSQL procedural language

postgis                | 2.1.8   | public     | PostGIS geometry, geography, and raster spatial types and functions

postgis_tiger_geocoder | 2.1.8   | tiger      | PostGIS tiger geocoder and reverse geocoder

postgis_topology       | 2.1.8   | topology   | PostGIS topology spatial types and functions


Error

(1)

[root@Darren2 postgis-2.1.8]# ./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-geosconfig=/opt/geos-3.4.2/bin/geos-config --with-projdir=/opt/proj-4.8.0/ --without-sfcgal

......

checking for xml2-config... no

configure: error: could not find xml2-config from libxml2 within the current path. You may need to try re-running configure with a --with-xml2config parameter.

解决方法:

查看是否存在xml2-config文件,结果不存在

[root@Darren2 postgis-2.1.8]# find / -name "xml2-config"

查看是否已经安装了libxml2和libxml2-devel

[root@Darren2 postgis-2.1.8]# rpm -qa |grep  libxml2

libxml2-2.7.6-14.el6.x86_64

libxml2-python-2.7.6-14.el6.x86_64

安装libxml2-devel:

[root@Darren2 postgis-2.1.8]# yum install libxml2-devel -y

[root@Darren2 postgis-2.1.8]# rpm -qa |grep  libxml2

libxml2-2.7.6-21.el6_8.1.x86_64

libxml2-python-2.7.6-21.el6_8.1.x86_64

libxml2-devel-2.7.6-21.el6_8.1.x86_64

可以看到此时已经有xml2-config文件

[root@Darren2 postgis-2.1.8]# find / -name "xml2-config"

/usr/bin/xml2-config

最后再执行上面的编译命令可成功。


(2)创建extension时报错

postgres=# create extension postgis;

ERROR:  could not load library "/usr/local/pgsql/lib/rtpostgis-2.1.so": libgdal.so.20: cannot open shared object file: No such file or directory

[root@Darren2 postgis-2.1.8]# ls -ltr /usr/local/pgsql/lib/rtpostgis-2.1.so

-rwxr-xr-x. 1 root root 1435637 Jul 12 05:44 /usr/local/pgsql/lib/rtpostgis-2.1.so

[root@Darren2 postgis-2.1.8]# ls -ltr /usr/local/pgsql/lib/libgdal.so.20

ls: cannot access /usr/local/pgsql/lib/libgdal.so.20: No such file or directory

[root@Darren2 postgis-2.1.8]# find / -name 'libgdal.so.20'

/usr/local/lib/libgdal.so.20

/home/tools/gdal-2.0.1/.libs/libgdal.so.20

[root@Darren2 postgis-2.1.8]# cp /usr/local/lib/libgdal.so.20 /usr/local/pgsql/lib/


相关内容

热门资讯

普京回答小男孩什么是胜利 据凤凰卫视报道,8月3日,俄罗斯总统普京与全俄“大变革”竞赛总决赛选手交谈时,13岁的年轻选手卡泽金...
菲尔兹奖与定点爆破 【文/观察者网专栏作者 边芹】近日舆论场一片喜庆,中国数学家得了菲尔兹奖。自1978年后,这类新闻便...
“救”在身边!4天2场“急”时... ▲红十字少年叶子豪与护士马莉开展紧急救援。台海网8月4日讯(导报记者 石程罗纳 通讯员 苏映红 陈雅...
Claude仅用8分钟,5年未... 新智元报道 25分钟,500个钱包被洗劫一空! 这几天,知名硬件钱包Coldcard暴雷,而引发这...
低价流量卡一夜消失!三大运营商... 最近几天,关于流量卡的讨论热度越来越高,原因很简单——流量卡没了。 最开始,只是有网友突然上传了一份...
薪火传家 执“戟”报国——王戟... 新华社长沙8月3日电 题:薪火传家 执“戟”报国——国防科技大学研究员王戟的家风故事新华社记者黄明、...
夏季战役第二阶段打响,乌方称俄... 据凤凰卫视报道,俄乌夏季战役第二阶段已经打响,顿巴斯中线多地陷入持续激战,俄军拿下了别列茨克定居点,...
顶尖AI人才争夺白热化 招聘逻... 图片来源:AI生成 证券时报记者 周春媚 财富的洪流永恒流动,但从不固守同一片河床,而是不断涌向新的...
婚外胚胎纠纷案,不容忽视的情理... 近日,上海一起婚外冷冻胚胎纠纷案持续搅动舆论漩涡。身患肺癌、长期休养的朱女士,意外发现丈夫与第三者伪...
抽水马桶水箱不进水的解决办法 步骤一、准备小刷子或是其他清洁工具;步骤二、打开水箱盖子;步骤三、将水箱的堵塞和污渍清理干净;步骤四...