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