]> git.openstreetmap.org Git - nominatim.git/blob - docs/Install-on-Centos-7.md
0ac1e53bcc04b0cc87857a02c3778c701d46c797
[nominatim.git] / docs / Install-on-Centos-7.md
1
2 *Note:* these installation instructions are also available in executable
3         form for use with vagrant under `vagrant/Install-on-Centos-7.sh`.
4
5 Installing the Required Software
6 ================================
7
8 These instructions expect that you have a freshly installed CentOS version 7.
9 Make sure all packages are up-to-date by running:
10
11     sudo yum update -y
12
13 The standard CentOS repositories don't contain all the required packages,
14 you need to enable the EPEL repository as well. To enable it on CentOS,
15 install the epel-release RPM by running:
16
17     sudo yum install -y epel-release
18
19 Now you can install all packages needed for Nominatim:
20
21     sudo yum install -y postgresql-server postgresql-contrib postgresql-devel postgis postgis-utils \
22                         git cmake make gcc gcc-c++ libtool policycoreutils-python \
23                         php-pgsql php php-pear php-pear-DB php-intl libpqxx-devel proj-epsg \
24                         bzip2-devel proj-devel geos-devel libxml2-devel boost-devel expat-devel zlib-devel
25
26 If you want to run the test suite, you need to install the following
27 additional packages:
28
29     sudo yum install -y python-pip python-Levenshtein python-psycopg2 \
30                         python-numpy php-phpunit-PHPUnit
31     pip install --user --upgrade pip setuptools lettuce==0.2.18 six==1.9 \
32                                  haversine Shapely pytidylib
33     sudo pear install PHP_CodeSniffer
34
35
36 System Configuration
37 ====================
38
39 The following steps are meant to configure a fresh CentOS installation
40 for use with Nominatim. You may skip some of the steps if you have your
41 OS already configured.
42
43 Creating Dedicated User Accounts
44 --------------------------------
45
46 Nominatim will run as a global service on your machine. It is therefore
47 best to install it under its own separate user account. In the following
48 we assume this user is called nominatim and the installation will be in
49 /srv/nominatim. To create the user and directory run:
50
51     sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim
52
53 You may find a more suitable location if you wish.
54
55 To be able to copy and paste instructions from this manual, export
56 user name and home directory now like this:
57
58     export USERNAME=nominatim
59     export USERHOME=/srv/nominatim
60
61 **Never, ever run the installation as a root user.** You have been warned.
62
63 Make sure that system servers can read from the home directory:
64
65     chmod a+x $USERHOME
66
67 Setting up PostgreSQL
68 ---------------------
69
70 CentOS does not automatically create a database cluster. Therefore, start
71 with initializing the database, then enable the server to start at boot:
72
73     sudo postgresql-setup initdb
74     sudo systemctl enable postgresql
75
76
77 Next tune the postgresql configuration, which is located in 
78 `/var/lib/pgsql/data/postgresql.conf`. See section *Postgres Tuning* in
79 [the installation page](Installation.md) for the parameters to change.
80
81 Now start 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 only for reading:
89
90
91     sudo -u postgres createuser -s $USERNAME
92     sudo -u postgres createuser apache
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 ```
102 sudo tee /etc/httpd/conf.d/nominatim.conf << EOFAPACHECONF
103 <Directory "$USERHOME/Nominatim/build/website">
104   Options FollowSymLinks MultiViews
105   AddType text/html   .php
106   DirectoryIndex search.php
107   Require all granted
108 </Directory>
109
110 Alias /nominatim $USERHOME/Nominatim/build/website
111 EOFAPACHECONF
112 ```
113
114
115
116
117 Then reload apache
118
119
120     sudo systemctl restart httpd
121
122
123 Adding SELinux Security Settings
124 --------------------------------
125
126 It is a good idea to leave SELinux enabled and enforcing, particularly
127 with a web server accessible from the Internet. At a minimum the
128 following SELinux labeling should be done for Nominatim:
129
130     sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/Nominatim/(website|lib|settings)(/.*)?"
131     sudo semanage fcontext -a -t lib_t "$USERHOME/Nominatim/module/nominatim.so"
132     sudo restorecon -R -v $USERHOME/Nominatim
133
134
135 Installing Nominatim
136 ====================
137
138 Building and Configuration
139 --------------------------
140
141 Get the source code from Github and change into the source directory
142
143
144
145     cd $USERHOME
146     git clone --recursive git://github.com/openstreetmap/Nominatim.git
147     cd Nominatim
148
149
150
151
152
153 When installing the latest source from github, you also need to
154 download the country grid:
155
156
157     wget -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz
158
159
160 The code must be built in a separate directory. Create this directory,
161 then configure and build Nominatim in there:
162
163
164     mkdir build
165     cd build
166     cmake $USERHOME/Nominatim
167     make
168
169 You need to create a minimal configuration file that tells nominatim
170 the name of your webserver user and the URL of the website:
171
172 ```
173 tee settings/local.php << EOF
174 <?php
175  @define('CONST_Database_Web_User', 'apache');
176  @define('CONST_Website_BaseURL', '/nominatim/');
177 EOF
178 ```
179
180
181 Nominatim is now ready to use. Continue with
182 [importing a database from OSM data](Import-and-Update.md).