Linux环境PostGIS源码编译安装
前提条件
安装PostGIS之前必须先安装proj,geos,gdal
1、安装proj8
下载proj-8.1.0.tar.gz :http://download.osgeo.org/proj/proj-8.1.0.tar.gz
[root@gyl soft]# tar xf proj-8.1.0.tar.gz
[root@gyl soft]# cd proj-8.1.0
[root@gyl proj-8.1.0]# ./configure --prefix=/usr/local/postgresql/plugin/proj
[root@gyl proj-8.1.0]# make && make install
#等待安装完成...
#配置和加载动态链接库:
[root@gyl proj-4.8.0]# vim /etc/ld.so.conf.d/proj-8.1.0.conf
/usr/local/postgresql/plugin/proj/lib
[root@gyl proj-4.8.0]# ldconfig
2、安装geos
下载geos-3.12.0.tar.bz2的链接为:http://download.osgeo.org/geos/geos-3.12.0.tar.bz2
[root@gyl soft]# bzip2 -d geos-3.12.0.tar.bz2
[root@gyl soft]# tar xf geos-3.12.0.tar
[root@gyl geos-3.12.0]# ./configure --prefix=/usr/local/postgresql/plugin/geos
......
[root@gyl geos-3.12.0]# make && make install
......
#配置和加载动态链接库:
[root@gyl geos-3.12.0]# vim /etc/ld.so.conf.d/geos-3.12.0.conf
/usr/local/postgresql/plugin/geos/lib64
[root@gyl geos-3.12.0]# ldconfig
3、安装gdal
下载gdal-3.7.3.tar.gz的链接为:http://download.osgeo.org/gdal/3.7.3/gdal-3.7.3.tar.gz
[root@gyl soft]#tar xf gdal-3.7.3.tar.gz
[root@gyl soft]# cd gdal-3.7.3
[root@gyl gdal-3.7.3]# ./configure --prefix=/usr/local/postgresql/plugin/gdal
[root@gyl gdal-3.7.3]#make && make install
......
#配置和加载动态链接库:
[root@gyl gdal-3.7.3]# vim /etc/ld.so.conf.d/gdal-3.7.3.conf
/usr/local/postgresql/plugin/gdal/lib64
[root@gyl gdal-3.7.3]# ldconfig
4、安装PostGIS
下载postgis-3.4.3.tar.gz的链接为:http://download.osgeo.org/postgis/source/postgis-3.4.3.tar.gz
[root@gyl soft]# tar xf postgis-3.4.3.tar.gz
[root@gyl soft]# cd postgis-3.4.3
[root@gyl postgis-3.1.0]# ./configure --prefix=/usr/local/postgresql/plugin/postgis --with-pgconfig=/usr/local/postgresql/bin/pg_config --with-geosconfig=/usr/local/postgresql/plugin/geos/bin/geos-config --with-gdalconfig=/usr/local/postgresql/plugin/gdal/bin/gdal-config --with-projdir=/usr/local/postgresql/plugin/proj
如果报这个错误信息:
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@node01 postgis-3.4.3]# find / -name "xml2-config"
查看是否已经安装了libxml2和libxml2-devel
[root@node01 postgis-3.4.3]# rpm -qa |grep libxml2
libxml2-2.7.6-14.el6.x86_64
libxml2-python-2.7.6-14.el6.x86_64
#没有libxml2-devel这个
下载libxml2-devel压缩包并安装
下载地址:http://mirror.centos.org/centos/7/os/x86_64/Packages/libxml2-devel-2.9.1-6.el7.5.x86_64.rpm
#安装
[root@gyl soft]# rpm -ivh libxml2-devel-2.9.1-6.el7.5.x86_64.rpm
如果出现error: Failed dependencies ,就在后面加参数 --nodeps --force,其作用是不再分析包之间的依赖关系而直接安装
#安装
[root@gyl soft]# rpm -ivh libxml2-devel-2.9.1-6.el7.5.x86_64.rpm --nodeps --force
如果出现错误:warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
解决办法:新建一个组和一个帐号
[root@gyl soft]#gourpadd mockbuild
[root@gyl soft]#useradd mockbuild -g mockbuild
编译安装
[root@gyl postgis-3.4.3]# make & make install
......
make[2]: Leaving directory `/home/tools/postgis-3.4.3/extensions/postgis_topology'
make[1]: Leaving directory `/home/tools/postgis-3.4.3/extensions'
5、检查PostGIS是否安装成功
在Navicat中查看是否有这个表
6、开启postgis插件
开启postgis插件
在sql中执行
create extension postgis;
用sql语句查询版本号:
select postgis_version();
用sql语句查询是否启用成功:
select * from pg_available_extensions where name like 'postgis%';
如果执行postGIS插件初始化的时候出现错误
解决方案:
环境变量配置问题解决方案如下:
切换到root用户:su root
打开: vim /etc/ld.so.conf
添加:/usr/local/lib
添加:/usr/local/pgsql/lib
退出执行 :ldconfig
重启pgsql: service postgresql restart
分类:
SQL / PostgreSQL
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
2021-10-23 C# MessageBox(WPF弹出对话确认框)