三。部署数据库:
都放到 /mapbar/app 下面
1. 安装postgres + postgis:
[pgsql安装]
tar -zxvf postgresql-8.2.23.tar.gz
cd postgresql-8.2.23
#./configure --prefix=/mapbar/app/pgsql
make
make install
groupadd postgres
useradd postgres -g postgres
mkdir -p /mapbar/app/pgsql/data
chown -R postgres /mapbar/app/pgsql/
su postgres #都需要使用这个登陆执行语句
# 初始化pgsql数据库
出现:
Encoding "GB18030" is not allowed as a server-side encoding
/mapbar/app/pgsql/bin/initdb -D /mapbar/app/pgsql/data --local=zh_CN.UTF8
vi /mapbar/app/pgsql/data/pg_hba.conf
host all all 0.0.0.0/0 trust
vi /mapbar/app/pgsql/data/postgresql.conf
listen_addresses = '*'
手动启动:
( /mapbar/app/pgsql/bin/postgres -D /mapbar/app/pgsql/data)
/mapbar/app/pgsql/bin/pg_ctl start -D /mapbar/app/pgsql/data/
(su - postgres)
**********************************************
测试:
# 创建一个test数据库
/mapbar/app/pgsql/bin/createdb test
# 登录到test
/mapbar/app/pgsql/bin/psql test
test=# alter user postgres with password 'postgres'
CREATE TABLE mytable (
id varchar(20),
name varchar(30));
**********************************************
1. 先安装Proj4和GEOS
1.1. 安装Proj-4.5.0
# tar zvxf proj-4.5.0.tar.gz
# cd proj-4.5.0
# ./configure --prefix=/mapbar/app/proj4
# make
# make install
1.2. 安装Geos-3.0.0Orc4
# tar jxf geos-3.0.0rc4.tar.bz2
# cd geos-3.0.0rc4
# ./configure --prefix=/mapbar/app/geos3
# make
# make install
centos6.3:
1.2. 安装geos-3.0.4rc1.tar.bz2
# tar jxf geos-3.0.4rc1.tar.bz2
# cd geos-3.0.4rc1
# ./configure --prefix=/mapbar/app/geos3
# make
# make install
2. 安装PostGIS-1.3.2
# tar xvzf postgis-1.3.2.tar.gz
# cd postgis-1.3.2
# ./configure --prefix=/mapbar/app/postgis --with-pgsql=/mapbar/app/pgsql/bin/pg_config --with-proj4=/mapbar/app/proj4 --with-geos=/mapbar/app/geos3/bin/geos-config
(设置安装位置为/opt/postgis,并且使用Proj4与GEOS3)
# make
# make install
root 下:
增加动态链接库:
vi /etc/ld.so.conf
/mapbar/app/lib
/mapbar/app/proj4/lib
/mapbar/app/geos3/lib
/mapbar/app/pgsql/lib
然后运行ldconfig使刚加入的库路径生效:
# /sbin/ldconfig
su postgres:
/mapbar/app/pgsql/bin/createdb template_postgis_20
******************************
createdb: could not connect to database postgres: could not connect to server: 没有那个文件或目录
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
没启动服务的错
******************************
/mapbar/app/pgsql/bin/createlang plpgsql template_postgis_20
cd /mapbar/app/postgis/share
/mapbar/app/pgsql/bin/psql -d template_postgis_20 -f lwpostgis.sql
/mapbar/app/pgsql/bin/psql -d template_postgis_20 -f lwpostgis_upgrade.sql
/mapbar/app/pgsql/bin/psql -d template_postgis_20 -f spatial_ref_sys.sql
(也可以使用客户端来生成:)
http://hi.baidu.com/niudetianxia/item/7eea14959691e9bb83d29597
http://blog.chinaunix.net/uid-11572501-id-2868563.html
**************** 导入正式数据,查看是否有数据 ********************