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