Linux源码安装PostGIS

本文涉及的产品
云原生数据库 PolarDB PostgreSQL 版,标准版 2核4GB 50GB
云原生数据库 PolarDB MySQL 版,通用型 2核8GB 50GB
简介:

官方网址:http://www.postgis.org/
下载源码安装包,我这里下载的是postgis的最新版本:postgis-2.3.3.tar.gz

环境依赖需要:

1 postgresql 数据库版本在9.2 到 9.4之间(需要提前安装)
2 需要安装依赖包:gcc 
                gmake or make 
                Proj4 version 4.6.0 or greater   (下载地址:http://proj4.org/download.html#linux)
                GEOS version 3.3 or greater      (下载地址:http://trac.osgeo.org/geos/)
                LibXML2, version 2.5.x or higher
                JSON-C, version 0.9 or higher     (下载:wget http://oss.metaparadigm.com/json-c/json-c-0.9.tar.gz)
                       ./configure
                        make 
                        sudo make install   
                GDAL, version 1.8 or higher      (下载地址:http://trac.osgeo.org/gdal/wiki/DownloadSource)

安装PostGIS

1 解压源码安装包:
  tar -zxvf postgis-2.3.3.tar.gz
2 安装:
(1)./configure --prefix=/opt/pg963 --with-pgconfig=/opt/pg963/bin/pg_config --with-gdalconfig=/usr/local/bin/gdal-config --with-geosconfig=/usr/local/bin/geos-config --with-xml2config=/usr/bin/xml2-config --with-projdir=/usr/local/share/proj --with-jsondir=/usr/local/include/json

报错:
checking for library containing GDALAllRegister... no
configure: error: could not find GDAL

解决方法:
:~/postgis-2.3.3$ sudo vi /etc/ld.so.conf

include /etc/ld.so.conf.d/*.conf
添加
/opt/pg963/lib

是参数生效
:~/postgis-2.3.3$ sudo /sbin/ldconfig -v

(2) make
(3) make install 

添加postgis 扩展

先登录安装postgis的数据库
postgres@:~$ /opt/pg963/bin/psql -p 6432
psql (9.6.3)
Type "help" for help.
 
postgres=# \dx
                 List of installed extensions
  Name   | Version |   Schema   |         Description          
---------+---------+------------+------------------------------
 plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
(1 row)

安装扩展
postgres=# create extension postgis;
CREATE EXTENSION
postgres=# \dx
                                     List of installed extensions
  Name   | Version |   Schema   |                             Description                             
---------+---------+------------+---------------------------------------------------------------------
 plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis | 2.3.3   | public     | PostGIS geometry, geography, and raster spatial types and functions
(2 rows)

postgres=# 

安装postgis_topology

postgres=# create extension postgis_topology;
CREATE EXTENSION
postgres=# \dx
                                                                    List of installed extensions
          Name          | Version |   Schema   |                                                     Description                                                     
------------------------+---------+------------+---------------------------------------------------------------------------------------------------------------------
 plpgsql                | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis                | 2.3.3   | public     | PostGIS geometry, geography, and raster spatial types and functions
 postgis_topology       | 2.3.3   | topology   | PostGIS topology spatial types and functions

安装postgis_tiger_geocoder

postgres=# CREATE EXTENSION postgis_tiger_geocoder FROM unpackaged;
ERROR:  required extension "fuzzystrmatch" is not installed
HINT:  Use CREATE EXTENSION ... CASCADE to install required extensions too.
postgres=# CREATE EXTENSION postgis_tiger_geocoder cascade;
ERROR:  could not open extension control file "/opt/pg963/share/postgresql/extension/fuzzystrmatch.control": 没有那个文件或目录

原因:fuzzystrmatch已经包含在了postgresql的源码扩展中,需要去postgresql源码目录中安装:
root@:~/postgresql-9.6.3/contrib/fuzzystrmatch# pwd
/home/~/postgresql-9.6.3/contrib/fuzzystrmatch

postgres=# CREATE EXTENSION postgis_tiger_geocoder cascade;
NOTICE:  installing required extension "fuzzystrmatch"
CREATE EXTENSION
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.3.3   | public     | PostGIS geometry, geography, and raster spatial types and functions
 postgis_tiger_geocoder | 2.3.3   | tiger      | PostGIS tiger geocoder and reverse geocoder
 postgis_topology       | 2.3.3   | topology   | PostGIS topology spatial types and functions

安装address_standardizer

root@:~/postgis-2.3.3/extensions/address_standardizer# make
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fpic -I/usr/local/include -I/usr/local/share/proj/include -I/usr/include/libxml2  -I/usr/local/include/json/include   -g -O0 -I. -I./ -I/opt/pg963/include/postgresql/server -I/opt/pg963/include/postgresql/internal -D_GNU_SOURCE   -c -o address_parser.o address_parser.c
address_parser.c:10:18: fatal error: pcre.h: 没有那个文件或目录

解决方法:
root@:~/postgis-2.3.3/extensions/address_standardizer# apt-get update
root@:~/postgis-2.3.3/extensions/address_standardizer# apt-get install libpcre3 libpcre3-dev
root@:~/postgis-2.3.3/extensions/address_standardizer# make
root@:~/postgis-2.3.3/extensions/address_standardizer# make install

postgres=# CREATE EXTENSION address_standardizer;
CREATE EXTENSION
postgres=# \dx
                                                                    List of installed extensions
          Name          | Version |   Schema   |                                                     Description                                                     
------------------------+---------+------------+---------------------------------------------------------------------------------------------------------------------
 address_standardizer   | 2.3.3   | public     | Used to parse an address into constituent elements. Generally used to support geocoding address normalization step.
 fuzzystrmatch          | 1.1     | public     | determine similarities and distance between strings
 plpgsql                | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis                | 2.3.3   | public     | PostGIS geometry, geography, and raster spatial types and functions
 postgis_tiger_geocoder | 2.3.3   | tiger      | PostGIS tiger geocoder and reverse geocoder
 postgis_topology       | 2.3.3   | topology   | PostGIS topology spatial types and functions
相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
关系型数据库 Linux PostgreSQL
linux安装postgresql、postgis并且使用geoserver发布服务
linux安装postgresql、postgis并且使用geoserver发布服务
|
Ubuntu 关系型数据库 Linux
在Linux环境下安装配置PostgreSQL 11和PostGIS 3
Ubuntu 首先添加PostgreSQL的官方源。 Ubuntu 16.04 sudo echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" > /etc/apt/sources.
2916 0
|
SQL 关系型数据库 Linux
|
18天前
|
Linux
Linux系统之whereis命令的基本使用
Linux系统之whereis命令的基本使用
54 23
Linux系统之whereis命令的基本使用
|
3月前
|
Linux 网络安全 数据安全/隐私保护
Linux 超级强大的十六进制 dump 工具:XXD 命令,我教你应该如何使用!
在 Linux 系统中,xxd 命令是一个强大的十六进制 dump 工具,可以将文件或数据以十六进制和 ASCII 字符形式显示,帮助用户深入了解和分析数据。本文详细介绍了 xxd 命令的基本用法、高级功能及实际应用案例,包括查看文件内容、指定输出格式、写入文件、数据比较、数据提取、数据转换和数据加密解密等。通过掌握这些技巧,用户可以更高效地处理各种数据问题。
384 8
|
3月前
|
监控 Linux
如何检查 Linux 内存使用量是否耗尽?这 5 个命令堪称绝了!
本文介绍了在Linux系统中检查内存使用情况的5个常用命令:`free`、`top`、`vmstat`、`pidstat` 和 `/proc/meminfo` 文件,帮助用户准确监控内存状态,确保系统稳定运行。
1207 6
|
3月前
|
Linux
在 Linux 系统中,“cd”命令用于切换当前工作目录
在 Linux 系统中,“cd”命令用于切换当前工作目录。本文详细介绍了“cd”命令的基本用法和常见技巧,包括使用“.”、“..”、“~”、绝对路径和相对路径,以及快速切换到上一次工作目录等。此外,还探讨了高级技巧,如使用通配符、结合其他命令、在脚本中使用,以及实际应用案例,帮助读者提高工作效率。
232 3
|
5天前
|
缓存 Ubuntu Linux
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
54 25
|
3天前
|
缓存 Linux
Linux查看内存命令
1. free free命令是最常用的查看内存使用情况的命令。它显示系统的总内存、已使用内存、空闲内存和交换内存的总量。 free -h • -h 选项:以易读的格式(如GB、MB)显示内存大小。 输出示例: total used free shared buff/cache available Mem: 15Gi 4.7Gi 4.1Gi 288Mi 6.6Gi 9.9Gi Swap: 2.0Gi 0B 2.0Gi • to
14 2
|
1月前
|
网络协议 Unix Linux
深入解析:Linux网络配置工具ifconfig与ip命令的全面对比
虽然 `ifconfig`作为一个经典的网络配置工具,简单易用,但其功能已经不能满足现代网络配置的需求。相比之下,`ip`命令不仅功能全面,而且提供了一致且简洁的语法,适用于各种网络配置场景。因此,在实际使用中,推荐逐步过渡到 `ip`命令,以更好地适应现代网络管理需求。
42 11