3 # This script sets up a Nominatim installation on a Ubuntu box.
5 # For more detailed installation instructions see also
6 # http://wiki.openstreetmap.org/wiki/Nominatim/Installation
8 ## Part 1: System preparation
10 ## During 'vagrant provision' this script runs as root and the current
11 ## directory is '/root'
15 ### maybe create ubuntu user
18 # if [[ ! `id -u $USERNAME` ]]; then
19 # useradd $USERNAME --create-home --shell /bin/bash
22 # echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/99-$USERNAME-user
23 # chmod 0440 /etc/sudoers.d/99-$USERNAME-user
24 # service sudo restart
26 # # add basic .profile
27 # cp -r .ssh .profile .bashrc /home/$USERNAME/
28 # chown -R $USERNAME /home/$USERNAME/.*
29 # chgrp -R $USERNAME /home/$USERNAME/.*
31 # # now ideally login as $USERNAME and continue
36 sudo apt-get update -qq
37 sudo apt-get upgrade -y
38 sudo apt-get install -y build-essential libgeos-dev libpq-dev libbz2-dev \
39 libtool automake libproj-dev libboost-dev libboost-system-dev \
40 libboost-filesystem-dev libboost-thread-dev libexpat-dev
41 sudo apt-get autoremove -y
43 # get arrow-keys working in terminal (e.g. editing in vi)
44 echo 'stty sane' >> ~/.bash_profile
45 echo 'export TERM=linux' >> ~/.bash_profile
46 source ~/.bash_profile
50 ### PostgreSQL 9.3 + PostGIS 2.1
53 sudo apt-get install -y postgresql-9.3-postgis-2.1 postgresql-contrib-9.3 postgresql-server-dev-9.3
54 # already included: proj-bin libgeos-dev
56 # make sure OS-authenticated users (e.g. $USERNAME) can access
57 sudo sed -i "s/ident/trust/" /etc/postgresql/9.3/main/pg_hba.conf
58 sudo sed -i "s/md5/trust/" /etc/postgresql/9.3/main/pg_hba.conf
59 sudo sed -i "s/peer/trust/" /etc/postgresql/9.3/main/pg_hba.conf
60 sudo /etc/init.d/postgresql restart
63 sudo -u postgres createuser -s $USERNAME
70 sudo apt-get install -y php5 php5-pgsql php-pear php-db
73 # get rid of some warning
74 # where is the ini file? 'php --ini'
75 echo "date.timezone = 'Etc/UTC'" | sudo tee /etc/php5/cli/conf.d/99-timezone.ini > /dev/null
82 sudo apt-get install -y libgeos-c1 libgeos++-dev libxml2-dev
84 ## Part 2: Nominatim installaion
86 # now ideally login as $USERNAME and continue
89 # If the Nominatim source is not being shared with the host, check out source.
90 if [ ! -d "Nominatim" ]; then
91 sudo apt-get install -y git
92 sudo -u $USERNAME git clone --recursive https://github.com/twain47/Nominatim.git
97 sudo -u $USERNAME ./autogen.sh
98 sudo -u $USERNAME ./configure
99 sudo -u $USERNAME make
104 LOCALSETTINGS_FILE='settings/local.php'
105 if [[ -e "$LOCALSETTINGS_FILE" ]]; then
106 echo "$LOCALSETTINGS_FILE already exist, writing to settings/local-vagrant.php instead."
107 LOCALSETTINGS_FILE='settings/local-vagrant.php'
110 # IP=`curl -s http://bot.whatismyipaddress.com`
114 @define('CONST_Database_DSN', 'pgsql://@/nominatim');
116 @define('CONST_Postgresql_Version', '9.3');
117 @define('CONST_Postgis_Version', '2.1');
119 @define('CONST_Website_BaseURL', 'http://$IP:8089/nominatim/');
120 " > $LOCALSETTINGS_FILE
129 ### Setup Apache/website
132 sudo -u postgres createuser -SDR www-data
137 # DirectoryIndex index.html
138 # ErrorDocument 403 /index.html
140 DocumentRoot "/var/www/"
142 <Directory "/var/www/nominatim/">
143 Options FollowSymLinks MultiViews
144 AddType text/html .php
147 ' | sudo tee /etc/apache2/sites-enabled/nominatim.conf > /dev/null
153 mkdir -m 755 /var/www/nominatim
154 chown $USERNAME /var/www/nominatim
155 sudo -u $USERNAME ./utils/setup.php --create-website /var/www/nominatim
158 # if you get 'permission denied for relation word', then try
159 # GRANT usage ON SCHEMA public TO "www-data";
160 # GRANT SELECT ON ALL TABLES IN SCHEMA public TO "www-data";
163 ## Test suite (Python)
164 ## https://github.com/twain47/Nominatim/tree/master/tests
166 apt-get install -y python-dev python-pip python-Levenshtein python-shapely \
167 python-psycopg2 tidy python-nose python-tidylib
168 pip install lettuce==0.2.18 six==1.7 haversine
171 ## https://github.com/twain47/Nominatim/tree/master/tests-php
172 apt-get install -y phpunit