linux编译安装postgresql,Linux环境下源码安装PostgreSQL+PostGIS

检查功能的函数,如Touches(), Contains(), Disjoint() 还有一些空间操作函数,如Intersection(), Union() 以及 Buffer()等 ,而Libxml2则提供了对GML和KML的操作函数,如ST_GeomFromGML(), ST_GeomFromKML()等,如果丧失了这样特性,空间数据库将会怎样

wget http://download.osgeo.org/proj/proj-4.8.0.tar.gz

wget http://download.osgeo.org/geos/geos-3.3.3.tar.bz2

wget http://postgis.refractions.net/download/postgis-1.5.4.tar.gz

proj 安装

tar -xvzf proj-4.8.0.tar.gz

cd proj-4.8.0

./configure --prefix=/usr/local/proj

make

make install

geos 安装

tar -jxvf geos-3.3.3.tar.bz2

cd geos-3.3.3

./configure --prefix=/usr/local/geos

make

make install

postGis 安装

tar -xvzf postgis-1.5.4.tar.gz

cd postgis-1.5.4

./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-projdir=/usr/local/proj --with-geosconfig=/usr/local/geos/bin/geos-config

PostGIS is now configured for x86_64-unknown-linux-gnu

-------------- Compiler Info -------------

C compiler: gcc -g -O2

C++ compiler: g++ -g -O2

-------------- Dependencies --------------

GEOS config: /usr/local/geos/bin/geos-config

GEOS version: 3.3.3

PostgreSQL config: /usr/local/pgsql/bin/pg_config

PostgreSQL version: PostgreSQL 9.1.3

PROJ4 version: 48

Libxml2 config: /usr/bin/xml2-config

Libxml2 version: 2.6.26

PostGIS debug level: 0

-------- Documentation Generation --------

xsltproc: /usr/bin/xsltproc

xsl style sheets:

dblatex:

convert:

make

make install

安装成功

error: configure: error: could not find pg_config within the current path. You may need to try re-running configure with a --with-pgconfig parameter. 解决: ./configure -prefix=/usr/local/postgis --with-pgsql=/usr/local/pgsql/bin/pg_config --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-proj=/usr/local/proj4 --with-geos=/usr/local/geos/bin/geos-config configure: error: could not find xml2-config from libxml2 within the current path. You may need to try re-running configure with a --with-xml2config parameter. 解决: apt-get install libxml2 apt-get install libxml2-dev

./configure -prefix=/usr/local/postgis --with-pgsql=/usr/local/pgsql/bin/pg_config --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-proj=/usr/local/proj4 --with-geos=/usr/local/geos/bin/geos-config

error:

configure: error:could not find geos-config within the current path. You may need to try re-running configure with a --with-geosconfig parameter.

解决: ./configure -prefix=/usr/local/postgis --with-pgsql=/usr/local/pgsql/bin/pg_config --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-proj=/usr/local/proj4 --with-geos=/usr/local/geos/bin/geos-config --with-geosconfig=/usr/local/geos/bin/geos-config error: configure: error: could not find proj_api.h - you may need to specify the directory of a PROJ.4 installation using --with-projdir 解决 : ./configure -prefix=/usr/local/postgis --with-pgsql=/usr/local/pgsql/bin/pg_config --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-proj=/usr/local/proj4 --with-geos=/usr/local/geos/bin/geos-config --with-geosconfig=/usr/local/geos/bin/geos-config --with-projdir=/usr/local/proj4 error: configure: error: gdal-config not found. Use --without-raster or try --with-gdalconfig=

解决: apt-cache search GDAL apt-get install libgdal1-dev configure: WARNING: unrecognized options: --with-pgsql, --with-proj, --with-geos

#./configure  --prefix=/usr/local/postgis --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-projdir=/usr/local/proj  --with-geosconfig=/usr/local/geos/bin/geos-config

*注意configure 成功时会出现

Geos config : /usr/local/

Postgresql config

Proj4

Libxml2 config

等字样 然后接着往下

(postgis编译过程中出错

configure: error: could not find xml2-config from libxml2 within the current path. You may need to try re-running configure with a --with-xml2config parameter)

就是缺少libxml2

rpm -ivh zlib-devel-1.2.3-25.el6.i686.rpm

rpm -ivh libxml2-devel-2.7.6-1.el6.i686.rpm

启动 postgres

su -postgres 切换到postgres用户下

pg_ctl -D /data/pgsql/ -l /data/pgsql/pgsql.log start 启动数据库

createdb template_postgis 创建数据库,此时,该数据库还没有具备空间特性

psql -f /usr/local/pgsql/share/contrib/postgis-1.5/postgis.sql -d template_postgis 执行postgis.sql脚本,创建相关空间数据库相关的函数,类型,操作符等 执行完这个脚本,该数据库就具有了空间特性了

psql template_postgis 连接到创建的空间数据库

select postgis_full_version(); 查询postgis的版本信息,包含用到的三个库信息

POSTGIS="1.5.4" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.8.0, 6 March 2012" LIBXML="2.6.26" USE_STATS

createdb [-U username] -T template_postgis my_spatial_db下次再创建数据库,只要以这个模板就可以了

安装完毕...

注意事项:

将/usr/local/geos/lib添加到/etc/ld.so.conf中,然后运行/sbin/ldconfig,这样做的目的是/etc/ld.so.conf列出

的路径下的库文件缓存到/etc/ld.so.cache 以供使用,否则下面的编译可以会出现找不到xxx库的错误。

在执行psql -f /usr/local/pgsql/share/contrib/postgis-1.5/postgis.sql -d template_postgis

出现 Error# could not load library "/usr/local/pgsql/lib/postgis-1.5.so": libproj.so.0: 无法打开共享对象文件: 没有那个文件或目录

解决方法:LD_LIBRARY_PATH 中加入 geos lib proj lib .

cd /usr/local/pgsql/lib/ 建议链接 ln -s /usr/local/proj/lib/libproj.so.0 libproj.so.0

设置远程可访问数据库

vi /usr/local/pgsql/data/postgresql.conf

把listen_address = 'localhost' 改为 listen_address = '*'

vi /usr/local/pgsql/data/pg_hba.conf 在文件最后加入: host all all 192.168.1.0/24 password

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值