4 ## During 'vagrant provision' this script runs as root and the current
5 ## directory is '/root'
9 ### maybe create ubuntu user
12 # if [[ ! `id -u $USERNAME` ]]; then
13 # useradd $USERNAME --create-home --shell /bin/bash
16 # echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/99-$USERNAME-user
17 # chmod 0440 /etc/sudoers.d/99-$USERNAME-user
18 # service sudo restart
20 # # add basic .profile
21 # cp -r .ssh .profile .bashrc /home/$USERNAME/
22 # chown -R $USERNAME /home/$USERNAME/.*
23 # chgrp -R $USERNAME /home/$USERNAME/.*
25 # # now ideally login as $USERNAME and continue
30 sudo apt-get update -qq
31 sudo apt-get upgrade -y
32 # sudo apt-get install -y git-core screen
33 sudo apt-get install -y build-essential libxml2-dev libgeos-dev libpq-dev libbz2-dev \
34 libtool automake libproj-dev libboost-dev libboost-system-dev \
35 libboost-filesystem-dev libboost-thread-dev
36 sudo apt-get autoremove -y
38 # get arrow-keys working in terminal (e.g. editing in vi)
39 echo 'stty sane' >> ~/.bash_profile
40 echo 'export TERM=linux' >> ~/.bash_profile
41 source ~/.bash_profile
45 ### PostgreSQL 9.3 + PostGIS 2.1
48 sudo apt-get install -y postgresql-9.3-postgis-2.1 postgresql-contrib-9.3 postgresql-server-dev-9.3
49 # already included: proj-bin libgeos-dev
51 # make sure OS-authenticated users (e.g. $USERNAME) can access
52 sudo sed -i "s/ident/trust/" /etc/postgresql/9.3/main/pg_hba.conf
53 sudo sed -i "s/md5/trust/" /etc/postgresql/9.3/main/pg_hba.conf
54 sudo sed -i "s/peer/trust/" /etc/postgresql/9.3/main/pg_hba.conf
55 sudo /etc/init.d/postgresql restart
58 sudo -u postgres createuser -s $USERNAME
65 sudo apt-get install -y php5 php5-pgsql php-pear
69 # get rid of some warning
70 # where is the ini file? 'php --ini'
71 echo "date.timezone = 'Etc/UTC'" | sudo tee /etc/php5/cli/conf.d/99-timezone.ini > /dev/null
78 sudo apt-get install -y libprotobuf-c0-dev protobuf-c-compiler \
79 libgeos-c1 libgeos++-dev \
82 # git clone --recursive https://github.com/twain47/Nominatim.git
85 # now ideally login as $USERNAME and continue
87 cd /home/vagrant/Nominatim
97 LOCALSETTINGS_FILE='settings/local.php'
98 if [[ -e "$LOCALSETTINGS_FILE" ]]; then
99 echo "$LOCALSETTINGS_FILE already exist, writing to settings/local-vagrant.php instead."
100 LOCALSETTINGS_FILE='settings/local-vagrant.php'
103 # IP=`curl -s http://bot.whatismyipaddress.com`
107 @define('CONST_Database_DSN', 'pgsql://@/nominatim');
109 @define('CONST_Postgresql_Version', '9.3');
110 @define('CONST_Postgis_Version', '2.1');
112 @define('CONST_Website_BaseURL', 'http://$IP:8089/nominatim/');
113 " > $LOCALSETTINGS_FILE
122 ### Setup Apache/website
125 sudo -u postgres createuser -SDR www-data
130 # DirectoryIndex index.html
131 # ErrorDocument 403 /index.html
133 DocumentRoot "/var/www/"
135 <Directory "/var/www/nominatim/">
136 Options FollowSymLinks MultiViews
137 AddType text/html .php
140 ' | sudo tee /etc/apache2/sites-enabled/nominatim.conf > /dev/null
143 sudo apache2ctl graceful
146 sudo mkdir -m 755 /var/www/nominatim
147 sudo chown $USERNAME /var/www/nominatim
148 ./utils/setup.php --threads 1 --create-website /var/www/nominatim
151 # if you get 'permission denied for relation word', then try
152 # GRANT usage ON SCHEMA public TO "www-data";
153 # GRANT SELECT ON ALL TABLES IN SCHEMA public TO "www-data";
156 ## Test suite (Python)
157 ## https://github.com/twain47/Nominatim/tree/master/tests
159 sudo apt-get install -y python-dev python-pip python-Levenshtein tidy
160 sudo pip install lettuce nose pytidylib haversine psycopg2 shapely
164 ## https://github.com/twain47/Nominatim/tree/master/tests-php
166 wget --no-clobber -q https://phar.phpunit.de/phpunit.phar
167 chmod +x phpunit.phar
168 sudo mv phpunit.phar /usr/local/bin/phpunit