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