Linux(Ubuntu)下PostGIS+Postgresql的安裝與配置(下)

本來之前想偷個懶,直接用apt-get install的方式安裝PostGIS,但總是有這樣那樣的問題,解決一個又來一個,最後乾脆把之前的卸載了源碼安裝了,終於沒有出現各種問題了,要安裝postgis需要先安裝geos、libxml2、proj4、gdal、json-c這幾個包我們就來一步一步的弄吧:
1.proj4,
1.1 下載地址:http://proj4.org/download.html,我選擇的是proj4-4.9.2.tar.gz,下載路徑我是在download裏邊
這裏寫圖片描述
1.2 然後進入終端,進入你下載包的目錄中去

# tar zxvf proj-4.9.2.tar.gz

1.3 進入解壓後的目錄

# cd proj-4.9.2

1.4 配置安裝路徑

# ./congigure --prefix=/opt/proj-4.9.2

1.5 編譯源碼

# make

1.6 安裝包

# make install

注意:1.4,1.5,1.6這三步是連着的,當一步比如自動編譯完了,你就開始安裝
因爲後邊geos\libxml2\gdal的安裝是一樣的,我就不每一步解釋了,就把東西寫出來就行了
2 geos安裝:http://trac.osgeo.org/geos,選擇geos-3.5.1.tar.bz2
這裏寫圖片描述

# tar jxvf geos-3.5.1.tar.bz2
# cd geos-3.5.1
# ./configure --prefix==/opt/geos-3.5.1
# make
# make install

3 libxml2安裝 : ftp://gd.tuwien.ac.at/pub/libxml/,選擇libxml2-2.9.0.tar.gz
這裏寫圖片描述
同樣的安裝方式:

# tar zxvf libxml2-2.9.0.tar.gz
# cd libxml2-2.9.0
# ./configure --prefix==/opt/libxml2-2.9.0
# make
# make install

這裏可能會在configure設置時出現問題:cannot remove ‘libtoolT’:No such file or directory
解決方法:

//進入configure文件,修改它
# gedit configure

找到其中一行(單獨的一行)RM" cfgfile”,把這一行刪除或者註釋掉,保存,然後在重新設置

# ./configure --prefix==/opt/libxml2-2.9.0
# make
# make install 

4 gdal安裝:http://trac.osgeo.org/gdal/wiki/DownloadSource,我下載的版本是1.10.0,選擇gdal-1.10.0.tar.gz
這裏寫圖片描述
Shell代碼:

# tar zxvf gdal-1.10.0.tar.gz
# cd gdal-1.10.0
# ./configure --prefix==/opt/gdal-1.10.0
# make
# make install

5 安裝json-c:https://s3.amazonaws.com/json-c_releases/releases/json-c-0.12.1.tar.gz
Shell代碼:

# tar zxvf json-c-0.12.1.tar.gz
# cd json-c-0.12.1
# ./configure --prefix==/opt/json-c-0.12.1
# make
# make install

6 安裝PostGIS:http://download.osgeo.org/postgis/source/ 選擇postgis-2.2.4.tar.gz
Shell代碼:

# tar zxvf postgis-2.2.4.tar.gz
# cd postgis-2.2.4
# ./configure --prefix==/opt/postgis-2.2.4
# make
# make install

7.爲數據庫創建postgis的擴展:
先登錄進去數據庫賬戶# su - postgres
然後爲對應的數據庫創建你需要的擴展:
在數據外(shell):
這裏寫圖片描述

在數據庫內(sql):
這裏寫圖片描述
最後你進入數據庫,查看是否成功

//進入數據庫sql控制檯
# psql yourdatabase
//查看當前數據庫的詳細信息
# /dt

就這樣,搞定了PostGIS的安裝配置!

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