]> git.openstreetmap.org Git - nominatim.git/blob - docs/install-on-centos-7.md
Merge pull request #219 from mizabrik/master
[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 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 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 aditional packages:
28
29     sudo yum install -y python-pip python-Levenshtein python-psycopg2 \
30                         php-phpunit-PHPUnit
31     pip install --user --upgrade pip setuptools lettuce==0.2.18 six==1.9 \
32                                  haversine Shapely pytidylib
33
34
35 System Configuration
36 ====================
37
38 The following steps are meant to configure a fresh CentOS installation
39 for use with Nominatim. You may skip some of the steps if you have your
40 OS already configured.
41
42 Creating Dedicated User Accounts
43 --------------------------------
44
45 Nominatim will run as a global service on your machine. It is therefore
46 best to install it under its own separate user account. In the following
47 we assume this user is called nominatim and the installation will be in
48 /srv/nominatim. To create the user and directory run:
49
50     sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim
51
52 You may find a more suitable location if you wish.
53
54 To be able to copy and paste instructions from this manual, export
55 user name and home directory now like this:
56
57     export USERNAME=nominatim
58     export USERHOME=/srv/nominatim
59
60 **Never, ever run the installation as a root user.** You have been warned.
61
62 Make sure that system servers can read from the home directory:
63
64     chmod a+x $USERHOME
65
66 Setting up PostgreSQL
67 ---------------------
68
69 CentOS does not automatically create a database cluster. Therefore, start
70 with initializing the database, then enable the server to start at boot:
71
72     sudo postgresql-setup initdb
73     sudo systemctl enable postgresql
74
75
76 Next tune the postgresql configuration, which is located in 
77 `/var/lib/pgsql/data/postgresql.conf`. See section *Postgres Tuning* in
78 [the installation page](Installation.md) for the parameters to change.
79
80 Now start the postgresql service after updating this config file.
81
82     sudo systemctl restart postgresql
83
84
85 Finally, we need to add two postgres users: one for the user that does
86 the import and another for the webserver ro access the database:
87
88
89     sudo -u postgres createuser -s $USERNAME
90     sudo -u postgres createuser apache
91
92
93 Setting up the Apache Webserver
94 -------------------------------
95
96 You need to create an alias to the website directory in your apache
97 configuration. Add a separate nominatim configuration to your webserver:
98
99 ```
100 sudo tee /etc/httpd/conf.d/nominatim.conf << EOFAPACHECONF
101 <Directory "$USERHOME/Nominatim/build/website">
102   Options FollowSymLinks MultiViews
103   AddType text/html   .php
104   Require all granted
105 </Directory>
106
107 Alias /nominatim $USERHOME/Nominatim/build/website
108 EOFAPACHECONF
109 ```
110
111
112
113
114 Then reload apache
115
116
117     sudo systemctl restart httpd
118
119
120 Adding SELinux Security Settings
121 --------------------------------
122
123 It is a good idea to leave SELinux enabled and enforcing, particularly
124 with a web server accessible from the Internet. At a minimum the
125 following SELinux labeling should be done for Nominatim:
126
127     sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/Nominatim/(website|lib|settings)(/.*)?"
128     sudo semanage fcontext -a -t lib_t "$USERHOME/Nominatim/module/nominatim.so"
129     sudo restorecon -R -v $USERHOME/Nominatim
130
131
132 Installing Nominatim
133 ====================
134
135 Building and Configuration
136 --------------------------
137
138 Get the source code from Github and change into the source directory
139
140
141
142     cd $USERHOME
143     git clone --recursive git://github.com/twain47/Nominatim.git
144     cd Nominatim
145
146
147
148
149
150 The code is built in a special directory. Create this directory,
151 then configure and build Nominatim in there:
152
153     mkdir build
154     cd build
155     cmake $USERHOME/Nominatim
156     make
157
158 You need to create a minimal configuration file that tells nominatim
159 the name of your webserver user and the URL of the website:
160
161 ```
162 tee settings/local.php << EOF
163 <?php
164  @define('CONST_Database_Web_User', 'apache');
165  @define('CONST_Website_BaseURL', '/nominatim/');
166 EOF
167 ```
168
169
170 Nominatim is now ready to use. Continue with
171 [importing a database from OSM data](Import_and_update.md).