postgres安装02--postgis
未完成目标:
http://www.cnblogs.com/bulvlanshan/p/9002919.html
1.远程登录
2.安装postgis-2.2.6
关于远程访问,只需要改两点,我们不在过多解释
1.postgresql.conf
listen_addresses项值设定为“*”
2.pg_hba.conf
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
重点postgis安装
我们选择的版本postgis-2.2.6
1.安装包
yum list|grep libxml2
yum -y install json-c json-c-devel
wget http://download.osgeo.org/geos/geos-3.5.1.tar.bz2
wget http://download.osgeo.org/proj/proj-4.9.3.tar.gz
wget http://download.osgeo.org/gdal/2.2.0/gdal-2.2.0.tar.gz
wget https://download.osgeo.org/postgis/source/postgis-2.2.6.tar.gz
2.安装组件
cd ../geos-3.5.1/
./configure --prefix=/home/postgres/geos
make && make install
cd ../proj-4.9.3/
./configure --prefix=/home/postgres/proj4
make && make install
cd ../gdal-2.2.0
./configure --prefix=/home/postgres/gdal --with-pg=/data/pgsql/bin/pg_config
make && make install
3.加载
[root@postgres-test01-0001 ~]# vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
/home/postgres/lib
/home/postgres/geos/lib
/home/postgres/proj4/lib
/home/postgres/gdal/lib
/data/pgsql/lib/
[root@postgres-test01-0001 ~]# ldconfig
4.最后一步安装postgis
cd ../postgis-2.2.6/
./configure --prefix=/home/postgres --with-gdalconfig=/home/postgres/gdal/bin/gdal-config --with-pgconfig=/data/pgsql/bin/pg_config --with-geosconfig=/home/postgres/geos/bin/geos-config --with-projdir=/home/postgres/proj4 --with-gdalconfig
make && make install
5.出错情况
postgis中执行./configure时,遇到 checking for library containing GDALAllRegister... no
将postgres库也要加入/etc/ld.so.conf
/data/pgsql/lib/
记得要:ldconfig
测试:
[root@postgres-test01-0001 postgis-2.2.6]# ldconfig -p | grep libpg
libpgtypes.so.3 (libc6,x86-64) => /data/pgsql/lib/libpgtypes.so.3
libpgtypes.so (libc6,x86-64) => /data/pgsql/lib/libpgtypes.so
6.测试
命令:
[postgres@postgres-test01-0001 ~]$ psql
psql (9.4.16)
Type "help" for help.
postgres=# create database gistest;
CREATE DATABASE
postgres=# \c gistest
You are now connected to database "gistest" as user "postgres".
gistest=# CREATE EXTENSION postgis;
CREATE EXTENSION
gistest=# CREATE EXTENSION postgis_topology;
CREATE EXTENSION
gistest=# SELECT postgis_full_version();
postgis_full_version
-------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------
POSTGIS="2.2.6 r16006" GEOS="3.5.1-CAPI-1.9.1 r4246" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 2.2.0, released 2017/04/28" LIBXML
="2.9.1" LIBJSON="0.11" TOPOLOGY RASTER
(1 row)
gistest=#