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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值