在ubuntu系统编译运行nominatim软件系统必须安装的软件有:
1.gcc
编译器
2.postgresql
数据库
3.proj4
4.geos
5.postgis
6.php
7.php-pgsql
8.pear::db
9.protobuf
10.wget
11.osmis
apt-get install build-essential libxml2-dev libgeos-dev libpq-devlibbz2-dev
apt-get install gcc proj-bin libgeos-c1 osmis
apt-get install php5 php-pear php5-pgsql php5-json php-db
apt-get install postgresql postgis postgresql-contribpostgresql-9.3-postgis
由于导入的地理数据格式为pbf,所以需要安装pbf支持软件
apt-get install libprotobuf-c0-dev protobuf-c-compiler
在debian系统中,geos运行需要另一个包
apt-get install libgeos++-dev
打开/etc/postgresql/9.3/main中的postgresql.conf文件,设置如下属性:
fsync = off
full_page_writes = off
具体命令为:
sudo vim /etc/postgresql/9.3/main中的postgresql.conf
wget
http://www.nominatim.org/release/nominatim-2.2.0.tar.bz2
tar xvf nominatim-2.2.0.tar.bz2
cd nominatim-2.2.0
./sutogen.sh
./configure
make
配置如下:
<?php
// paths
@define('const_postgresql_version', '9.3');
@define('const_postgis_version', '2.1');
@define('const_website_baseurl', 'http://localhost/nominatim/');
1.新建导入账户
adduser <自己的用户名,example:mypg>
passwd <密码>
su – postgres
psql -template1
界面切换到数据库的交互界面,敲入如下命令:
create user <自己的用户名,example:mypg>with password <密码>
退出数据库交互界面,敲入命令:\q
切换到root
新建网站用户:
createuser -sdr www-data
更改nominatim的读取权限:
chmod +x /soft_src
chmod +x /soft_src/nominatim-2.2.0
chmod +x /soft_src/nominatim-2.2.0/module
倒入下载的osm数据,并为其建立索引:
下载数据地址为(pbf格式):
http://download.geofabrik.de/openstreetmap/
导入pbf数据:
./nominatim-2.2.0/utils/setup.php --osm-file<自己下载的pbf数据,shanghai.osm.pbf>--all
[--osm2pgsql-cache ]
添加额外字段:
./nominatim-2.2.0/utils/specialphrases.php –countries >specialphrases_countries.sql
psql -d nominatim -f specialphrases_countries.sql
./nominatim-2.2.0/utils/specialphrases.php –wiki-import >specialphrases.sql
psql -d nominatim -f specialphrases.sql
建立网站:
sudo mkdir -m 755 /var/www/nominatim
sudo chown <your username> /var/www/nominatim
./utils/setup.php --create-website /var/www/nominatim
配置apache环境:
打开/etc/apache2/sites-enabled/000-default,在最后添加如下内容:
<directory "/var/www/nominatim/">
options followsymlinks multiviews
addtype text/html .php
</directory>
重启apache服务:
service apache2 restart
增加mypg对数据库nominatim的权限:
psql template1
grant all privileges on database nominatim to mypg
\q
浏览器登陆:http://http://localhost/nominatim/
看www-data用户有没有数据库读写权限,若没有,则打开/etc/apache2/envvars,修改
export apache_run_user=mypg
export apache_run_group=mypg