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