##接上篇,上篇講述了Postgresql的安裝,此篇介紹postgis的安裝
##附上上篇鏈接:https://www.cnblogs.com/giser-s/p/11195419.html
二、安裝PostGIS
1. 安裝epel
#網上資料說,由於2.0中引入了GDAL和JSON等依賴關系,PostGIS有很多依賴關系,因此安裝之前需要先安裝依賴項。
[root@psql_master ~]# yum -y install epel-release
2. 安裝PostGIS
#版本號格式為:_前為postgis版本,后面為postgresql版本(這里是網上的說法,暫時還沒驗證,本想裝postgis2.2,可是這個命令下裝的是2.4,具體什么原因待研究)
[root@psql_master ~]# sudo yum install postgis2_94
#實驗證明如果要裝postgis2.2版本,可以命令改為
[root@psql_master ~]# sudo yum install postgis22_94
3. 新建擴展
#安裝完postgis后,並不表示可以使用空間數據庫功能了,需要先激活數據庫上的PostGIS功能,然后才能存儲空間數據
1)先切換到用戶
[root@psql_master ~]# sudo -i -u postgres
2)創建測試用戶/數據庫
-bash-4.2$ createuser test_user
-bash-4.2$ createdb test_db -O test_user
#上面創建test_db命令 -o是英文字母o,不是零
3)連接到測試數據庫
-bash-4.2$ psql -d test_db
4)在數據庫上啟用PostGIS擴展
test_db=# CREATE EXTENSION postgis;
5)驗證
test_db=# SELECT PostGIS_version();
4. 將Arcgis安裝目錄下的so文件,復制到linux下postgresql安裝目錄lib下(/usr/pgsql-9.4/lib)
4. 至此結束
#arcsde連postgis,與windows下無異,參照https://www.cnblogs.com/giser-s/p/10345285.html(方法二)