]> git.openstreetmap.org Git - nominatim.git/blob - vagrant/install-on-ubuntu-16.sh
Merge pull request #506 from mtmail/primary-vagrant-vm
[nominatim.git] / vagrant / install-on-ubuntu-16.sh
1 #!/bin/bash
2 #
3 # hacks for broken vagrant box      #DOCS:
4 sudo rm -f /var/lib/dpkg/lock       #DOCS:
5 sudo update-locale LANG=en_US.UTF-8 #DOCS:
6 #
7 # *Note:* these installation instructions are also available in executable
8 #         form for use with vagrant under vagrant/install-on-ubuntu-16.sh.
9 #
10 # Installing the Required Software
11 # ================================
12 #
13 # These instructions expect that you have a freshly installed Ubuntu 16.04.
14 #
15 # Make sure all packages are are up-to-date by running:
16 #
17
18     sudo apt-get update -qq
19     sudo apt-get upgrade -y
20
21 # Now you can install all packages needed for Nominatim:
22
23     sudo apt-get install -y build-essential cmake g++ libboost-dev libboost-system-dev \
24                             libboost-filesystem-dev libexpat1-dev zlib1g-dev libxml2-dev\
25                             libbz2-dev libpq-dev libgeos-dev libgeos++-dev libproj-dev \
26                             postgresql-server-dev-9.5 postgresql-9.5-postgis-2.2 postgresql-contrib-9.5 \
27                             apache2 php php-pgsql libapache2-mod-php php-pear php-db \
28                             git
29
30 # If you want to run the test suite, you need to install the following
31 # additional packages:
32
33     sudo apt-get install -y python-dev python-pip python-levenshtein python-shapely \
34                             python-psycopg2 tidy python-nose python-tidylib \
35                             python-numpy phpunit
36
37     pip install --user lettuce==0.2.18 six==1.7 haversine
38
39 #
40 # System Configuration
41 # ====================
42 #
43 # The following steps are meant to configure a fresh Ubuntu installation
44 # for use with Nominatim. You may skip some of the steps if you have your
45 # OS already configured.
46 #
47 # Creating Dedicated User Accounts
48 # --------------------------------
49 #
50 # Nominatim will run as a global service on your machine. It is therefore
51 # best to install it under its own separate user account. In the following
52 # we assume this user is called nominatim and the installation will be in
53 # /srv/nominatim. To create the user and directory run:
54 #
55 #     sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim
56 #
57 # You may find a more suitable location if you wish.
58 #
59 # To be able to copy and paste instructions from this manual, export
60 # user name and home directory now like this:
61 #
62     export USERNAME=vagrant        #DOCS:    export USERNAME=nominatim
63     export USERHOME=/home/vagrant  #DOCS:    export USERHOME=/srv/nominatim
64 #
65 # **Never, ever run the installation as a root user.** You have been warned.
66 #
67 # Make sure that system servers can read from the home directory:
68
69     chmod a+x $USERHOME
70
71 # Setting up PostgreSQL
72 # ---------------------
73 #
74 # Tune the postgresql configuration, which is located in 
75 # `/etc/postgresql/9.5/main/postgresql.conf`. See section *Postgres Tuning* in
76 # [the installation page](Installation.md) for the parameters to change.
77 #
78 # Restart the postgresql service after updating this config file.
79
80     sudo systemctl restart postgresql
81
82 #
83 # Finally, we need to add two postgres users: one for the user that does
84 # the import and another for the webserver which should access the database
85 # for reading only:
86 #
87
88     sudo -u postgres createuser -s $USERNAME
89     sudo -u postgres createuser www-data
90
91 #
92 # Setting up the Apache Webserver
93 # -------------------------------
94 #
95 # You need to create an alias to the website directory in your apache
96 # configuration. Add a separate nominatim configuration to your webserver:
97
98 #DOCS:```
99 sudo tee /etc/apache2/conf-available/nominatim.conf << EOFAPACHECONF
100 <Directory "$USERHOME/build/website"> #DOCS:<Directory "$USERHOME/Nominatim/build/website">
101   Options FollowSymLinks MultiViews
102   AddType text/html   .php
103   Require all granted
104 </Directory>
105
106 Alias /nominatim $USERHOME/build/website  #DOCS:Alias /nominatim $USERHOME/Nominatim/build/website
107 EOFAPACHECONF
108 #DOCS:```
109
110 sudo sed -i 's:#.*::' /etc/apache2/conf-available/nominatim.conf #DOCS:
111
112 #
113 # Then enable the configuration and restart apache
114 #
115
116     sudo a2enconf nominatim
117     sudo systemctl restart apache2
118
119 #
120 # Installing Nominatim
121 # ====================
122 #
123 # Building and Configuration
124 # --------------------------
125 #
126 # Get the source code from Github and change into the source directory
127 #
128 if [ "x$1" == "xyes" ]; then  #DOCS:
129
130     cd $USERHOME
131     git clone --recursive git://github.com/twain47/Nominatim.git
132 #DOCS:    cd Nominatim
133
134 else                               #DOCS:
135     cd $USERHOME                   #DOCS:
136 fi                                 #DOCS:
137
138 # The code must be built in a separate directory. Create this directory,
139 # then configure and build Nominatim in there:
140
141     mkdir build
142     cd build
143     cmake $USERHOME/Nominatim
144     make
145
146 # You need to create a minimal configuration file that tells nominatim
147 # where it is located on the webserver:
148
149 #DOCS:```
150 tee settings/local.php << EOF
151 <?php
152  @define('CONST_Website_BaseURL', '/nominatim/');
153 EOF
154 #DOCS:```
155
156
157 # Nominatim is now ready to use. Continue with
158 # [importing a database from OSM data](Import_and_update.md).