linux环境下创建postgis数据库,linux下搭建postgresql、postgis、pg_pathman环境步骤详解...
操作系統:centOS6.6
安裝postgreSQL9.6.2
安裝命令:
./postgresql-9.6.3-2-linux-x64.run
之后按照圖形界面操作安裝,語言選擇zh_CN UTF-8
安裝geos-3.6.0(會報錯,暫時不用管)
安裝命令:
tar xjvfgeos-3.6.0.tar.bz2
cd geos-3.6.0
./configure ?–prefix=/opt/geos
make
make install
安裝proj-4.9.3
安裝命令:
tar zxvf proj-4.9.3.tar.gz
cd proj-4.9.3
./configure?–prefix=/opt/proj
make
make install
安裝gdal-2.1.2
安裝命令:
yum install gcc-c++
tar zxvf gdal-2.1.2.tar.gz
cd gdal-2.1.2
./configure?–prefix=/opt/gdal
make
make install
刪除geos相關的文件夾
cd /opt
rm –rf geos
rm –rf geos-3.6.0
重新安裝geos-3.6.0,步驟如上
安裝postgis
安裝命令:
export LD_LIBRARY_PATH=/opt/PostgreSQL/9.6/lib
export PATH=/opt/PostgreSQL/9.6/bin:$PATH
export MANPATH=/opt/PostgreSQL/9.6/share/man:$MANPATH
tar zxvf postgis-2.3.2.tar.gz
cd postgis-2.3.2
./configure -prefix=/opt/postgis
報錯如下:
checking for xml2-config… no
configure: error: could not find xml2-config from libxml2within the current path. You may need to try re-running configure with a–with-xml2config parameter.
checking for xml2-config… no
configure: error: could not find xml2-config from libxml2within the current path. You may need to try re-running configure with a–with-xml2config parameter.
檢查libxml2的安裝情況:
rpm -qa |grep? libxml2
重新安裝libxml2和libxml2-devel包(需要聯網)
yum install libxml2
yum install libxml2-devel -y
安裝完之后查找xml2-config文件是否存在:
find / -name “xml2-config”
如果輸出結果如下表示成功:
/usr/bin/xml2-config
繼續執行如下命令:
./configure –prefix=/opt/postgis/–with-pgconfig=/opt/PostgreSQL/9.6/bin/pg_config–with-geosconfig=/opt/geos/bin/geos-config –with-projdir=/opt/proj/–with-gdalconfig=/opt/gdal/bin/gdal-config–with-xml2config=/usr/bin/xml2-config
make
make install
打開postgresql終端執行
SELECT name,default_version,installed_version FROM pg_available_extensions WHERE name LIKE’postgis%’ ;
執行命令:
cp/opt/geos/lib/libgeos_c.so.1?/opt/PostgreSQL/9.6/lib
執行命令:
cp/opt/proj/lib/libproj.so.12 ?/opt/PostgreSQL/9.6/lib
執行命令:
cp /opt/gdal/lib/libgdal.so.20?/opt/PostgreSQL/9.6/lib
創建postgis擴展
安裝pg_pathman
安裝命令:
cd /opt
unzippg_pathman-1.2.1.zip
export PATH=/opt/PostgreSQL/9.6/bin:$PATH
cd pg_pathman-1.2.1
cp -r/opt/PostgreSQL/9.6/include/openssl ?/usr/include/
cp -r/opt/PostgreSQL/9.6/include/gssapi ?/usr/include/
make USE_PGXS=1
make USE_PGXS=1install
cd/opt/PostgreSQL/9.6/data/
vimpostgresql.conf
#將shared_preload_libraries注釋取消,將下面變量賦值進去
shared_preload_libraries= ‘pg_pathman,pg_stat_statements’
按esc退出,:wq!保存退出!
重啟數據庫服務:
service postgresql-9.6 restart
創建pg_pathman擴展
開啟遠程訪問:
vi /opt/PostgreSQL/9.6/data/postgresql.conf
修改#listen_addresses= ‘localhost’? 為? listen_addresses=’*’
當然,此處‘*’也可以改為任何你想開放的服務器IP
信任遠程連接
vi /opt/PostgreSQL/9.6/data/pg_hba.conf
修改如下內容,信任指定服務器連接
關閉防火墻
service iptables stop
chkconfig iptables off
service iptables status
重啟數據庫服務:
servicepostgresql-9.6 restart
轉載自:https://blog.csdn.net/qq_26629277/article/details/75579166
總結
以上是生活随笔為你收集整理的linux环境下创建postgis数据库,linux下搭建postgresql、postgis、pg_pathman环境步骤详解...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 烧鸭的功效与作用、禁忌和食用方法
- 下一篇: linux误删ssh不上,误删opens