2015-06-25 05:21:32 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-02-09 01:44:27 +03:00
|
|
|
# This script sets up a Nominatim installation on a Ubuntu box.
|
|
|
|
#
|
|
|
|
# For more detailed installation instructions see also
|
|
|
|
# http://wiki.openstreetmap.org/wiki/Nominatim/Installation
|
|
|
|
|
|
|
|
## Part 1: System preparation
|
2015-06-25 05:21:32 +03:00
|
|
|
|
|
|
|
## During 'vagrant provision' this script runs as root and the current
|
|
|
|
## directory is '/root'
|
|
|
|
USERNAME=vagrant
|
|
|
|
|
|
|
|
###
|
|
|
|
### maybe create ubuntu user
|
|
|
|
###
|
|
|
|
|
|
|
|
# if [[ ! `id -u $USERNAME` ]]; then
|
|
|
|
# useradd $USERNAME --create-home --shell /bin/bash
|
|
|
|
#
|
|
|
|
# # give sudo power
|
|
|
|
# echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/99-$USERNAME-user
|
|
|
|
# chmod 0440 /etc/sudoers.d/99-$USERNAME-user
|
|
|
|
# service sudo restart
|
|
|
|
#
|
|
|
|
# # add basic .profile
|
|
|
|
# cp -r .ssh .profile .bashrc /home/$USERNAME/
|
|
|
|
# chown -R $USERNAME /home/$USERNAME/.*
|
|
|
|
# chgrp -R $USERNAME /home/$USERNAME/.*
|
|
|
|
#
|
|
|
|
# # now ideally login as $USERNAME and continue
|
|
|
|
# su $USERNAME -l
|
|
|
|
# fi
|
|
|
|
|
|
|
|
|
|
|
|
sudo apt-get update -qq
|
|
|
|
sudo apt-get upgrade -y
|
2016-02-06 20:49:12 +03:00
|
|
|
sudo apt-get install -y build-essential libgeos-dev libpq-dev libbz2-dev \
|
2016-03-01 00:26:22 +03:00
|
|
|
libtool cmake libproj-dev libboost-dev libboost-system-dev \
|
2015-12-23 00:57:38 +03:00
|
|
|
libboost-filesystem-dev libboost-thread-dev libexpat-dev
|
2015-06-25 05:21:32 +03:00
|
|
|
sudo apt-get autoremove -y
|
|
|
|
|
|
|
|
# get arrow-keys working in terminal (e.g. editing in vi)
|
|
|
|
echo 'stty sane' >> ~/.bash_profile
|
|
|
|
echo 'export TERM=linux' >> ~/.bash_profile
|
|
|
|
source ~/.bash_profile
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
### PostgreSQL 9.3 + PostGIS 2.1
|
|
|
|
###
|
|
|
|
|
|
|
|
sudo apt-get install -y postgresql-9.3-postgis-2.1 postgresql-contrib-9.3 postgresql-server-dev-9.3
|
|
|
|
# already included: proj-bin libgeos-dev
|
|
|
|
|
|
|
|
# make sure OS-authenticated users (e.g. $USERNAME) can access
|
|
|
|
sudo sed -i "s/ident/trust/" /etc/postgresql/9.3/main/pg_hba.conf
|
|
|
|
sudo sed -i "s/md5/trust/" /etc/postgresql/9.3/main/pg_hba.conf
|
|
|
|
sudo sed -i "s/peer/trust/" /etc/postgresql/9.3/main/pg_hba.conf
|
|
|
|
sudo /etc/init.d/postgresql restart
|
|
|
|
|
|
|
|
# creates the role
|
|
|
|
sudo -u postgres createuser -s $USERNAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
### PHP for frontend
|
|
|
|
###
|
2015-12-23 00:57:38 +03:00
|
|
|
sudo apt-get install -y php5 php5-pgsql php-pear php-db
|
2015-06-25 05:21:32 +03:00
|
|
|
|
|
|
|
|
|
|
|
# get rid of some warning
|
|
|
|
# where is the ini file? 'php --ini'
|
|
|
|
echo "date.timezone = 'Etc/UTC'" | sudo tee /etc/php5/cli/conf.d/99-timezone.ini > /dev/null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
### Nominatim
|
|
|
|
###
|
2016-02-06 20:49:12 +03:00
|
|
|
sudo apt-get install -y libgeos-c1 libgeos++-dev libxml2-dev
|
2015-06-25 05:21:32 +03:00
|
|
|
|
2016-02-09 01:44:27 +03:00
|
|
|
## Part 2: Nominatim installaion
|
|
|
|
|
2015-06-25 05:21:32 +03:00
|
|
|
# now ideally login as $USERNAME and continue
|
2016-02-09 01:44:27 +03:00
|
|
|
cd /home/$USERNAME
|
2016-02-06 20:49:12 +03:00
|
|
|
|
2016-02-09 01:44:27 +03:00
|
|
|
# If the Nominatim source is not being shared with the host, check out source.
|
2016-02-06 20:49:12 +03:00
|
|
|
if [ ! -d "Nominatim" ]; then
|
|
|
|
sudo apt-get install -y git
|
2016-03-01 00:26:22 +03:00
|
|
|
sudo -H -u $USERNAME git clone --recursive https://github.com/twain47/Nominatim.git
|
2016-02-06 20:49:12 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd Nominatim
|
2016-03-01 00:26:22 +03:00
|
|
|
sudo -u $USERNAME mkdir build-vagrant
|
|
|
|
cd build-vagrant
|
|
|
|
sudo -u $USERNAME cmake ..
|
2016-02-09 01:44:27 +03:00
|
|
|
sudo -u $USERNAME make
|
2015-06-25 05:21:32 +03:00
|
|
|
chmod +x ./
|
|
|
|
chmod +x ./module
|
|
|
|
|
|
|
|
|
2015-07-09 04:45:31 +03:00
|
|
|
LOCALSETTINGS_FILE='settings/local.php'
|
|
|
|
if [[ -e "$LOCALSETTINGS_FILE" ]]; then
|
|
|
|
echo "$LOCALSETTINGS_FILE already exist, writing to settings/local-vagrant.php instead."
|
|
|
|
LOCALSETTINGS_FILE='settings/local-vagrant.php'
|
|
|
|
fi
|
|
|
|
|
2015-06-25 05:21:32 +03:00
|
|
|
# IP=`curl -s http://bot.whatismyipaddress.com`
|
|
|
|
IP=localhost
|
|
|
|
echo "<?php
|
|
|
|
// General settings
|
|
|
|
@define('CONST_Database_DSN', 'pgsql://@/nominatim');
|
|
|
|
// Paths
|
|
|
|
@define('CONST_Postgresql_Version', '9.3');
|
|
|
|
@define('CONST_Postgis_Version', '2.1');
|
|
|
|
// Website settings
|
|
|
|
@define('CONST_Website_BaseURL', 'http://$IP:8089/nominatim/');
|
2015-07-09 04:45:31 +03:00
|
|
|
" > $LOCALSETTINGS_FILE
|
2015-06-25 05:21:32 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
### Setup Apache/website
|
|
|
|
###
|
|
|
|
|
2015-07-09 04:45:31 +03:00
|
|
|
sudo -u postgres createuser -SDR www-data
|
2015-06-25 05:21:32 +03:00
|
|
|
|
|
|
|
echo '
|
|
|
|
Listen 8089
|
|
|
|
<VirtualHost *:8089>
|
|
|
|
# DirectoryIndex index.html
|
|
|
|
# ErrorDocument 403 /index.html
|
|
|
|
|
|
|
|
DocumentRoot "/var/www/"
|
|
|
|
|
|
|
|
<Directory "/var/www/nominatim/">
|
|
|
|
Options FollowSymLinks MultiViews
|
|
|
|
AddType text/html .php
|
|
|
|
</Directory>
|
|
|
|
</VirtualHost>
|
|
|
|
' | sudo tee /etc/apache2/sites-enabled/nominatim.conf > /dev/null
|
|
|
|
|
|
|
|
|
2016-03-13 04:06:46 +03:00
|
|
|
service apache2 graceful
|
2015-06-25 05:21:32 +03:00
|
|
|
|
|
|
|
|
2016-02-09 01:44:27 +03:00
|
|
|
mkdir -m 755 /var/www/nominatim
|
|
|
|
chown $USERNAME /var/www/nominatim
|
|
|
|
sudo -u $USERNAME ./utils/setup.php --create-website /var/www/nominatim
|
2015-06-25 05:21:32 +03:00
|
|
|
|
|
|
|
|
|
|
|
# if you get 'permission denied for relation word', then try
|
|
|
|
# GRANT usage ON SCHEMA public TO "www-data";
|
|
|
|
# GRANT SELECT ON ALL TABLES IN SCHEMA public TO "www-data";
|
|
|
|
|
|
|
|
##
|
|
|
|
## Test suite (Python)
|
|
|
|
## https://github.com/twain47/Nominatim/tree/master/tests
|
|
|
|
##
|
2016-02-09 01:44:27 +03:00
|
|
|
apt-get install -y python-dev python-pip python-Levenshtein python-shapely \
|
2015-12-23 00:57:38 +03:00
|
|
|
python-psycopg2 tidy python-nose python-tidylib
|
2016-02-09 01:44:27 +03:00
|
|
|
pip install lettuce==0.2.18 six==1.7 haversine
|
2015-06-25 05:21:32 +03:00
|
|
|
|
|
|
|
## Test suite (PHP)
|
|
|
|
## https://github.com/twain47/Nominatim/tree/master/tests-php
|
2016-02-09 01:44:27 +03:00
|
|
|
apt-get install -y phpunit
|
2015-06-25 05:21:32 +03:00
|
|
|
|
|
|
|
|