源碼postgresql安裝postgis擴展模塊

1、安裝前環境,postgresql=9.6.3,版本最好在9.6-10.0之間
源碼安裝postgresql鏈接:https://blog.csdn.net/a13568hki/article/details/105431663
2.安裝Proj4

wget http://download.osgeo.org/proj/proj-4.9.3.tar.gz
tar -xf proj-4.9.3.tar.gz
cd proj-4.9.3
./configure --prefix=/usr/proj
make
make install
echo "/usr/proj/lib" > /etc/ld.so.conf.d/proj-4.9.3.conf
ldconfig

3.安裝GEOS

wget http://download.osgeo.org/geos/geos-3.6.1.tar.bz2
tar -jxf geos-3.6.1.tar.bz2
cd geos-3.6.1
./configure --prefix=/usr/geos
make
make install
echo "/usr/geos/lib" > /etc/ld.so.conf.d/geos-3.6.1.conf
ldconfig

4.安裝GDAL

wget http://download.osgeo.org/gdal/2.1.2/gdal-2.1.2.tar.gz
tar -xf gdal-2.1.2.tar.gz
cd gdal-2.1.2
./configure --prefix=/usr/gdal
make
make install
echo "/usr/gdal/lib" > /etc/ld.so.conf.d/gdal-2.1.2.conf
ldconfig

4、安裝postgis依賴

yum -y install perl-devel
yum -y install libxml2-devel

5.安裝postgis

wget http://download.osgeo.org/postgis/source/postgis-2.2.5.tar.gz
tar -xf postgis-2.2.5.tar.gz
cd postgis-2.2.5
./configure --with-pgconfig=/opt/postgresql/bin/pg_config --with-geosconfig=/usr/geos/bin/geos-config --with-gdalconfig=/usr/gdal/bin/gdal-config  --with-projdir=/usr/proj  --prefix=/opt/postgresql/share/contrib/postgis
make
make install

6、使PostGIS可用
想要在PostgreSQL中使用PostGIS插件,安裝只是第一步。每個數據庫想要使用PostGIS必須先在該數據庫中使PostGIS可用。假設我們想在gisdb這個數據庫中使用PostGIS,先進入gisdb數據庫,執行以下步驟:

[postgres@c3349c483e7c postgis-2.2.5]$ psql
proxydb=# create extension postgis;
CREATE EXTENSION
proxydb=# create extension postgis_topology ;
CREATE EXTENSION
proxydb=#

7 查看是否安裝成功
在gisdb數據庫中輸入\dx,查看已安裝的插件

postgres=# \dx
                                         List of installed extensions
       Name       | Version |   Schema   |                             Description                             
------------------+---------+------------+---------------------------------------------------------------------
 plpgsql          | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis          | 2.2.5   | public     | PostGIS geometry, geography, and raster spatial types and functions
 postgis_topology | 2.2.5   | topology   | PostGIS topology spatial types and functions
(3 rows)

可以看到已經安裝了postgis和postgis_topology。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章