安装 postgresql + proj + geos + postgis
环境 centos 5.4 / 5.5
安装包:
1)、postgresql-8.4.13.tar.gz
2)、proj-4.7.0.tar.gz
3)、geos-3.2.3.tar.bz2
4)、postgis-1.5.1.tar.gz
把这几个文件上传到/root目录下
1、
新建个用户组,及用户
# groupadd postgres
# useradd postgres
# passwd postgres
//设置密码为postgres
2、
安装上面的几个安装包
1)安装postgresql
包
#tar –zvxf postgresql-8.4.13.tar.gz
#cd postgresql-8.4.13
#./configure –prefix=/usr/local/pgsql
#make
#make install
这样在/usr/local就生成了个pgsql目录
继续
#mkdir /usr/local/pgsql/data
#cd
/usr/local
把pgsql目录交给postgres
#chown
-R postgres:postgres pgsql
postgressql初始化
#su postgres
#cd /usr/local/pgsql/bin
#./initdb –D /usr/local/pgsql/data
配置postgresql文件
#vi /usr/local/pgsql/data/pg_hba.conf
在最后面加上
host all all 192.168.10.1/24 md5
//加这个行表示192.168.10.*的用户必须以密码方式登录
#vi /usr/local/pgsql/data/postgresql.conf
找到#listen_address=’localhost’
修改为listen_address=’*’
修改#port=5432
为port=5432
修改#password
=on 为password
=on
这样就Ok了
下面开始设置用service postgresql start启动(如果没有的话,必须跳到目录启动)
#cd /root/postgresql-8.4.13/contrib/start-scripts
#cp linux /etc/init.d/
#chmod a+x /etc/init.d/postgresql
#chown –R postgres:postgres /etc/init.d/postgresql
#vim /etc/profile
加入下面几句
export PGSQL_HOME =/usr/local/pgsql
export PATH=$PATH:$PGSQL_HOME/bin
export PROJ_HOME=/usr/local/proj
export GEOS_HOME=/usr/local/geos
export LD_LIBRARY_PATH = $PGSQL_HOME/bin:$PROJ_HOME/bin:$GEOS_HOME/bin
2)安装proj包
#tar -zvxf proj-4.7.0.tar.gz
#cd proj-4.7.0
#./configure –prefix=/usr/local/proj
#make
#make install
3)安装
geos包
#tar xvfj geos-3.2.3.tar.bz2
#cd geos-3.2.3
#./configure –prefix=/usr/local/geos
#make
#make install
*注意如果coufigure出现g++
not found
就必须安装g++
连网情况下可以yum install g++
如果没有连网,可以先查下系统gcc的版本
#rpm –qa | grep gcc
然后去下载gcc-c++安装包
4)、安装
postgis包
#tar -zvxf postgis-1.5.1.tar.gz
#cd postgis-1.5.1
#./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
#make
#make install
成功之后在/usr/local/pgsql/share/contrib/postgis-1.5
重启电脑
#service iptables stop
#su postgres
#service postgresql start
start ok
#createdb postgis
#psql postgis
postgis#=alter user postgres with password ‘postgres’;
postgis#=\q
5)新建个模版
#createdb template_postgis
#createlang plpgsql template_postgis
#cd /usr/local/pgsql/share/contrib/postgis-1.5
#psql –d template_postgis –f postgis.sql
#psql –d template_postgis –f spatial_ref_sys.sql
转载自:https://blog.csdn.net/clyhs2009/article/details/7920830