]> git.openstreetmap.org Git - nominatim.git/blob - docs/Installation.md
update US postcode file from 2017 Tiger data
[nominatim.git] / docs / Installation.md
1 Nominatim installation
2 ======================
3
4 This page contains generic installation instructions for Nominatim and its
5 prerequisites. There are also step-by-step instructions available for
6 the following operating systems:
7
8   * [Ubuntu 16.04](Install-on-Ubuntu-16.md)
9   * [CentOS 7.2](Install-on-Centos-7.md)
10
11 These OS-specific instructions can also be found in executable form
12 in the `vagrant/` directory.
13
14 Prerequisites
15 -------------
16
17 ### Software
18
19 For compiling:
20
21   * [cmake](https://cmake.org/)
22   * [libxml2](http://xmlsoft.org/)
23   * a recent C++ compiler
24
25 Nominatim comes with its own version of osm2pgsql. See the
26 [osm2pgsql README](../osm2pgsql/README.md) for additional dependencies
27 required for compiling osm2pgsql.
28
29 For running tests:
30
31   * [behave](http://pythonhosted.org/behave/)
32   * [Psycopg2](http://initd.org/psycopg)
33   * [nose](https://nose.readthedocs.io)
34   * [phpunit](https://phpunit.de)
35
36 For running Nominatim:
37
38   * [PostgreSQL](http://www.postgresql.org) (9.1 or later)
39   * [PostGIS](http://postgis.refractions.net) (2.0 or later)
40   * [PHP](http://php.net) (5.4 or later)
41   * PHP-pgsql
42   * PHP-intl (bundled with PHP)
43   * [PEAR::DB](http://pear.php.net/package/DB)
44   * a webserver (apache or nginx are recommended)
45
46 For running continuous updates:
47
48   * [pyosmium](http://osmcode.org/pyosmium/)
49
50 ### Hardware
51
52 A minimum of 2GB of RAM is required or installation will fail. For a full
53 planet import 32GB of RAM or more strongly are recommended.
54
55 For a full planet install you will need about 500GB of hard disk space (as of
56 June 2016, take into account that the OSM database is growing fast). SSD disks
57 will help considerably to speed up import and queries.
58
59 On a 6-core machine with 32GB RAM and SSDs the import of a full planet takes
60 a bit more than 2 days. Without SSDs 7-8 days are more realistic.
61
62
63 Setup of the server
64 -------------------
65
66 ### PostgreSQL tuning
67
68 You might want to tune your PostgreSQL installation so that the later steps
69 make best use of your hardware. You should tune the following parameters in
70 your `postgresql.conf` file.
71
72     shared_buffers (2GB)
73     maintenance_work_mem (10GB)
74     work_mem (50MB)
75     effective_cache_size (24GB)
76     synchronous_commit = off
77     checkpoint_segments = 100 # only for postgresql <= 9.4
78     checkpoint_timeout = 10min
79     checkpoint_completion_target = 0.9
80
81 The numbers in brackets behind some parameters seem to work fine for
82 32GB RAM machine. Adjust to your setup.
83
84 For the initial import, you should also set:
85
86     fsync = off
87     full_page_writes = off
88
89 Don't forget to reenable them after the initial import or you risk database
90 corruption. Autovacuum must not be switched off because it ensures that the
91 tables are frequently analysed.
92
93 ### Webserver setup
94
95 The `website/` directory in the build directory contains the configured
96 website. Include the directory into your webbrowser to serve php files
97 from there.
98
99 #### Configure for use with Apache
100
101 Make sure your Apache configuration contains the required permissions for the
102 directory and create an alias:
103
104     <Directory "/srv/nominatim/build/website">
105       Options FollowSymLinks MultiViews
106       AddType text/html   .php
107       DirectoryIndex search.php
108       Require all granted
109     </Directory>
110     Alias /nominatim /srv/nominatim/build/website
111
112 `/srv/nominatim/build` should be replaced with the location of your
113 build directory.
114
115 After making changes in the apache config you need to restart apache.
116 The website should now be available on http://localhost/nominatim.
117
118 #### Configure for use with Nginx
119
120 Use php-fpm as a deamon for serving PHP cgi. Install php-fpm together with nginx.
121
122 By default php listens on a network socket. If you want it to listen to a
123 Unix socket instead, change the pool configuration (`pool.d/www.conf`) as
124 follows:
125
126     ; Comment out the tcp listener and add the unix socket
127     ;listen = 127.0.0.1:9000
128     listen = /var/run/php5-fpm.sock
129
130     ; Ensure that the daemon runs as the correct user
131     listen.owner = www-data
132     listen.group = www-data
133     listen.mode = 0666
134
135 Tell nginx that php files are special and to fastcgi_pass to the php-fpm
136 unix socket by adding the location definition to the default configuration.
137
138     root /srv/nominatim/build/website;
139     index search.php index.html;
140     location ~ [^/]\.php(/|$) {
141         fastcgi_split_path_info ^(.+?\.php)(/.*)$;
142         if (!-f $document_root$fastcgi_script_name) {
143             return 404;
144         }
145         fastcgi_pass unix:/var/run/php5-fpm.sock;
146         fastcgi_index search.php;
147         include fastcgi.conf;
148     }
149
150 Restart the nginx and php5-fpm services and the website should now be available
151 on http://localhost/.
152
153
154 Now continue with [importing the database](Import-and-Update.md).