以CentOS为例,在Linux下离线安装PostGIS 2_96。基本思路是在互联网计算机下载PostGIS依赖,把依赖rpm拷贝到离线计算机,配置本地yum源,然后进行安装。
1、在联网计算机上安装pgdg-centos96-9.6-3.noarch.rpm,自动生成repo地址;
[root@centos7]# rpm -ivh pgdg-centos96-9.6-3.noarch.rpm
2、下载postgis扩展依赖包
[root@centos7]# yum install --downloaddir=/home/pg --downloadonly postgis23_96
总共下载到26个rpm
-rw-r--r--. 1 root root 28668 12月 9 06:39 armadillo-8.300.0-1.el7.x86_64.rpm
-rw-r--r--. 1 root root 103424 2月 17 2014 arpack-3.1.3-2.el7.x86_64.rpm
-rw-r--r--. 1 root root 540436 10月 2 2017 cfitsio-3.370-10.el7.x86_64.rpm
-rw-r--r--. 1 root root 259588 2月 27 05:20 CGAL-4.7-1.rhel7.x86_64.rpm
-rw-r--r--. 1 root root 64540 7月 10 2014 CharLS-1.0-5.el7.x86_64.rpm
-rw-r--r--. 1 root root 32938 2月 23 07:38 freexl-1.0.5-1.el7.x86_64.rpm
-rw-r--r--. 1 root root 4595088 2月 27 05:23 gdal-libs-1.11.4-12.rhel7.x86_64.rpm
-rw-r--r--. 1 root root 555780 2月 27 05:21 geos36-3.6.2-3.1.rhel7.x86_64.rpm
-rw-r--r--. 1 root root 1670532 8月 24 2017 hdf5-1.8.12-10.el7.x86_64.rpm
-rw-r--r--. 1 root root 33820 10月 25 2017 libaec-1.0.2-1.el7.x86_64.rpm
-rw-r--r--. 1 root root 433272 7月 19 2014 libdap-3.13.1-2.el7.x86_64.rpm
-rw-r--r--. 1 root root 725248 2月 27 05:20 libgeotiff-1.4.0-1.rhel7.x86_64.rpm
-rw-r--r--. 1 root root 32864 2月 5 2014 libgta-1.0.4-1.el7.x86_64.rpm
-rw-r--r--. 1 root root 709772 12月 13 2015 netcdf-4.3.3.1-5.el7.x86_64.rpm
-rw-r--r--. 1 root root 254364 7月 26 2014 ogdi-3.2.0-0.19.beta2.el7.x86_64.rpm
-rw-r--r--. 1 root root 4585392 3月 23 03:18 openblas-openmp-0.2.20-6.el7.x86_64.rpm
-rw-r--r--. 1 root root 156389 2月 20 22:26 openjpeg2-2.3.0-6.el7.x86_64.rpm
-rw-r--r--. 1 root root 5464004 4月 10 21:11 postgis23_96-2.3.7-1.rhel7.x86_64.rpm
-rw-r--r--. 1 root root 1436940 2月 27 07:54 postgresql96-9.6.8-1PGDG.rhel7.x86_64.rpm
-rw-r--r--. 1 root root 580804 2月 27 07:54 postgresql96-contrib-9.6.8-1PGDG.rhel7.x86_64.rpm
-rw-r--r--. 1 root root 322316 2月 27 07:54 postgresql96-libs-9.6.8-1PGDG.rhel7.x86_64.rpm
-rw-r--r--. 1 root root 185756 2月 5 2014 proj-4.8.0-4.el7.x86_64.rpm
-rw-r--r--. 1 root root 220660 2月 27 05:22 proj49-4.9.3-3.rhel7.x86_64.rpm
-rw-r--r--. 1 root root 14080 2月 27 05:20 SFCGAL-1.2.2-1.rhel7.x86_64.rpm
-rw-r--r--. 1 root root 1745324 2月 27 05:20 SFCGAL-libs-1.2.2-1.rhel7.x86_64.rpm
-rw-r--r--. 1 root root 184152 12月 7 07:57 SuperLU-5.2.0-5.el7.x86_64.rpm
-rw-r--r--. 1 root root 899472 3月 11 2016 xerces-c-3.1.1-8.el7_2.x86_64.rpm
把下载的安装包拷贝到离线计算机/home/pg下
3、离线计算机安装PostgreSQL 9.6,根据依赖提示调整先后顺序
postgresql96-libs-9.6.8-1PGDG.rhel7.x86_64.rpm
postgresql96-9.6.8-1PGDG.rhel7.x86_64.rpm
postgresql96-contrib-9.6.8-1PGDG.rhel7.x86_64.rpm
postgresql96-devel-9.6.8-1PGDG.rhel7.x86_64.rpm
postgresql96-server-9.6.8-1PGDG.rhel7.x86_64.rpm
[root@centos7]# mv /etc/yum.repos.d/* /home/centos-yum.bak
5、搭建本地yum源,编写本地yum源pg.repo
[root@centos7]# vim /etc/yum.repos.d/pg.repo
name=pg
baseurl=file:///home/pg
enable=1
gpgcheck=0
priority=1
6、生成repomd.xml
[root@centos7 home]#creatrepo ./pg/
生成/home/pg/repodata/repomd.xml
7、清除yum缓存
[root@centos7]#yum clean all
[root@centos7]#yum list
列出rpm包
8、安装postgis
[root@centos7]# yum install postgis23_96