官方提供完整的安裝說明,網路上也有 docker image 能使用。以下使用 Ubuntu 16.04 來安裝,postgreSQL 版本是 9.5。
使用 apt-get 來安裝
sudo apt-get install -y build-essential cmake g++ libboost-dev libboost-system-dev \
libboost-filesystem-dev libexpat1-dev zlib1g-dev libxml2-dev\
libbz2-dev libpq-dev libproj-dev \
postgresql-server-dev-9.5 postgresql-9.5-postgis-2.2 \
postgresql-contrib-9.5 \
apache2 php php-pgsql libapache2-mod-php php-pear php-db \
php-intl git
建立 user,並給予權限。sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim
export USERNAME=nominatim
export USERHOME=/srv/nominatim
chmod a+x $USERHOME
## 建立 postgres 帳號
sudo -u postgres createuser -s $USERNAME
sudo -u postgres createuser www-data
新增 nominatim.conf 檔,內容如下。sudo tee /etc/apache2/conf-available/nominatim.conf << EOFAPACHECONF
<directory build="" ominatim-3.2.0="" website="">
Options FollowSymLinks MultiViews
AddType text/html .php
DirectoryIndex search.php
Require all granted
</directory>
Alias /nominatim $USERHOME/Nominatim-3.2.0/build/website
EOFAPACHECONF
重啟服務sudo a2enconf nominatim
sudo service apache2 restart
安裝 nominatim servicecd $USERHOME
wget https://nominatim.org/release/Nominatim-3.2.0.tar.bz2
tar xf Nominatim-3.2.0.tar.bz2
cd Nominatim-3.2.0
## 開始 build
mkdir build
cd build
cmake ..
make
## 下載資料,提高準確度
cd /srv/nominatim/Nominatim-3.2.0/data
wget https://www.nominatim.org/data/wikipedia_article.sql.bin
wget https://www.nominatim.org/data/wikipedia_redirect.sql.bin
## 匯入下載的資料
cd /srv/nominatim/Nominatim-3.2.0/build
wget https://download.geofabrik.de/asia/taiwan-latest.osm.pbf
su nominatim
./utils/setup.php --osm-file taiwan-latest.osm.pbf --all 2>&1 | tee setup.log
測試http://${host}:${port}/nominatim/reverse.php?format=html&lat=25.009575&lon=121.45948&zoom=16
http://${host}:${port}/nominatim/search.php?q=1,%E7%A5%A5%E5%92%8C%E4%B8%80%E8%B7%AF%E6%9D%B1%E6%AE%B5,%E5%A4%AA%E4%BF%9D%E5%B8%82,%20%E5%98%89%E7%BE%A9%E7%B8%A3,%20%E8%87%BA%E7%81%A3%E7%9C%81,%20612,%20%E8%87%BA%E7%81%A3&format=html
當要新增其他國家的圖資時,該怎麼作?https://help.openstreetmap.org/questions/15505/import-more-osm-files-in-to-nominatim
Reference
https://nominatim.org/release-docs/latest/appendix/Install-on-Ubuntu-16/
沒有留言:
張貼留言