CentOS7安装PostGIS过程


本文采用源码安装方式。
1、首先去官网下载安装包,下载地址为http://postgis.net/source/
在此页面,也提示了编译安装所依赖的插件有如下几个:
1)postgresql-devel or postgresql-dev packages
2) GEOS, Proj.4, GDAL, LibXML2 and JSON-C

2、先安装依赖的插件。
1)postgresql-devel可在安装PostgreSQL时顺便安装,过程见CentOS7安装PostgreSQL9.5过程
2)geos下载地址为https://trac.osgeo.org/geos/,安装过程

tar jxvf geos-3.5.0.tar.bz2  
cd geos-3.5.0  
./configure  
make  
make install 

3)proj4下载地址为https://trac.osgeo.org/proj/,安装过程

tar xzvf proj-4.9.1.tar.gz  
cd proj-4.9.1  
./configure  
make  
make install

4)gdal官网为http://gdal.org/,安装过程

tar xzvf gdal-2.0.2.tar.gz  
cd gdal-2.0.2  
./configure  
make  
make install

5)LibXML2下载地址为http://www.xmlsoft.org/downloads.html,安装过程

rpm -ivh libxml2-2.9.1-5.el7_1.2.x86_64.rpm

如果提示依赖xz-devel-5.1.2-12alpha.el7.x86_64.rpm和zlib-devel-1.2.7-15.el7.x86_64.rpm,则可在http://rpmfind.net/linux/rpm2html/search.php这里搜寻rpm。
6)JSON-C下载地址为https://github.com/json-c/json-c,安装过程

解压缩后
$ cd json-c
$ sh autogen.sh

followed by

$ ./configure
$ make
$ make install

To build and run the test programs:

$ make check

3、安装PostGIS

tar zxvf postgis-2.2.2.tar.gz  
cd postgis-2.2.2  
./configure --with-pgconfig=/usr/pgsql-9.5/bin/pg_config  
make  
make install

4、检查postgis安装是否正确,连接数据库执行:

postgres=# select * from pg_available_extensions where name like 'postgis%';
          name          | default_version | installed_version |                 
              comment                               
------------------------+-----------------+-------------------+-----------------
----------------------------------------------------
 postgis_topology       | 2.2.2           |                   | PostGIS topology
 spatial types and functions
 postgis_tiger_geocoder | 2.2.2           |                   | PostGIS tiger ge
ocoder and reverse geocoder
 postgis                | 2.2.2           |                   | PostGIS geometry
, geography, and raster spatial types and functions
(3 rows)

有以上3条就说明PostGIS安装成功了。

5、安装成功后,登录pgsql命令行,安装gis扩展。

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
#CREATE EXTENSION fuzzystrmatch;未测试

如果创建扩展失败,找不到geos或proj的共享库,则需要编辑/etc/ld.so.conf文件。geos和proj默认安装在/usr/local中,它们的共享库都在/usr/local/lib中,因此编辑/etc/ld.so.conf文件,在下面加入一行/usr/local/lib,然后退出,运行 ldconfig 生成 /etc/ld.so.cache。 ld.so 加载共享库的时候,会从 ld.so.cache 查找,不然会找不到刚添加的路径。

完成。

转载自:https://blog.csdn.net/wu_boy/article/details/51209959

You may also like...