]> git.openstreetmap.org Git - nominatim.git/blob - vagrant/install-on-centos-7.sh
1780a6cd81c369fa519f38ff1c87c117aaade76a
[nominatim.git] / vagrant / install-on-centos-7.sh
1 #!/bin/bash
2 #
3 # Installing the Required Software
4 # ================================
5 #
6 # *Note:* these installation instructions are also available in executable
7 #         form for use with vagrant in the vagrant/ directory.
8 #
9 # These instructions expect that you have a freshly installed CentOS version 7.
10 # Make sure all packages are are up-to-date by running:
11 #
12     sudo yum update -y
13 #
14 # Setting up Repositories
15 # -----------------------
16 #
17 # The standard CentOS repositories don't contain all the required packages,
18 # you need to enable the EPEL repository as well. To enable it on CentOS,
19 # install the epel-release RPM by running:
20
21     sudo yum install -y epel-release
22
23 #
24 # Getting the Software Packages
25 # -----------------------------
26 #
27 # Now you can install all packages needed for Nominatim:
28
29     sudo yum install -y postgresql-server postgresql-contrib postgresql-devel postgis postgis-utils \
30                         git cmake make gcc gcc-c++ libtool policycoreutils-python \
31                         php-pgsql php php-pear php-pear-DB libpqxx-devel proj-epsg \
32                         bzip2-devel proj-devel geos-devel libxml2-devel boost-devel expat-devel zlib-devel
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=vagrant        #DOCS:    export USERNAME=nominatim
58     export USERHOME=/home/vagrant  #DOCS:    export USERHOME=/srv/nominatim
59 #
60 # **Never, ever run the installation as a root user.** You have been warned.
61 #
62 # Setting up PostgreSQL
63 # ---------------------
64 #
65 # CentOS does not automatically create a database cluster. Therefore, start
66 # with initializing the database, then enable the server to start at boot:
67
68     sudo postgresql-setup initdb
69     sudo systemctl enable postgresql
70
71 #
72 # Next tune the postgresql configuration, which is located in 
73 # `/var/lib/pgsql/data/postgresql.conf`. See
74 # [the wiki](http://wiki.openstreetmap.org/wiki/Nominatim/Installation#PostgreSQL_Tuning_and_Configuration) for the parameters to change.
75 #
76 # Now start the postgresql service after updating this config file.
77
78     sudo systemctl restart postgresql
79
80 #
81 # Finally, we need to add two postgres users: one for the user that does
82 # the import and another for the webserver ro access the database:
83 #
84
85     sudo -u postgres createuser -s $USERNAME
86     sudo -u postgres apache
87
88 #
89 # Setting up the Apache Webserver
90 # -------------------------------
91 #
92 # You need to create an alias to the website directory in your apache
93 # configuration. This can be most easily done by XXX
94
95 #
96 # Adding SELinux Security Settings
97 # --------------------------------
98 #
99 # It is a good idea to leave SELinux enabled and enforcing, particularly
100 # with a web server accessible from the Internet. At a minimum the
101 # following SELinux labeling should be done for Nominatim:
102
103     sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/Nominatim/(website|lib|settings)(/.*)?"
104     sudo semanage fcontext -a -t lib_t "$USERHOME/Nominatim/module/nominatim.so"
105     sudo restorecon -R -v $USERHOME/Nominatim
106
107 #
108 # Installing Nominatim
109 # ====================
110 #
111 # Building and Configuration
112 # --------------------------
113 #
114 # Get the source code from Github and change into the source directory
115 #
116
117     cd $USERHOME
118     sudo -u $USERNAME git clone --recursive git://github.com/twain47/Nominatim.git
119
120 # The code is built in a special directory. Create this directory,
121 # then configure and build Nominatim in there:
122
123 #DOCS:    cd Nominatim
124     sudo -u $USERNAME mkdir build
125     cd build
126     sudo -u $USERNAME cmake ../Nominatim
127     sudo -u $USERNAME make
128
129 # You need to create a minimal configuration file that tells nominatim
130 # the name of your webserver user:
131
132 #DOCS:```
133 sudo -u $USERNAME tee << EOF
134 <?php
135  @define('CONST_Database_Web_User', 'apache');
136 EOF
137 #DOCS:```
138
139 # There are lots of configuration settings you can tweak. Have a look
140 # at `settings/settings.php` for a full list. Most should have a sensible default.
141 # If you plan to import a large dataset (e.g. Europe, North America, planet),
142 # you should also enable flatnode storage of node locations. With this
143 # setting enabled, node coordinates are stored in a simple file instead
144 # of the database. This will save you import time and disk storage.
145 # Add to your settings/local.php:
146 #
147 #     @define('CONST_Osm2pgsql_Flatnode_File', '/path/to/flatnode.file');
148 #
149 #
150 # Downloading additional data
151 # ---------------------------
152 #
153 # The following data is optional but download is strongly recommended:
154 #
155 #     sudo -u $USERNAME wget -O data/wikipedia_article.sql.bin http://www.nominatim.org/data/wikipedia_article.sql.bin
156 #     sudo -u $USERNAME wget -O data/wikipedia_redirect.sql.bin http://www.nominatim.org/data/wikipedia_redirect.sql.bin
157 #     sudo -u $USERNAME wget -O data/gb_postcode_data.sql.gz http://www.nominatim.org/data/gb_postcode_data.sql.gz
158 #
159 #
160 # Initial Import of the Data
161 # --------------------------
162 #
163 # **Attention:** first try the import with a small excerpt, for example from Geofabrik.
164 #
165 # Download the data to import and load the data with the following command:
166 #
167 #     ./utils/setup.php --osm-file <your data file> --all [--osm2pgsql-cache 28000] 2>&1 | tee setup.log
168 #
169 # The --osm2pgsql-cache parameter is optional but strongly recommended for
170 # planet imports. It sets the node cache size for the osm2pgsql import part
171 # (see -C parameter in osm2pgsql help). 28GB are recommended for a full planet
172 # imports, for excerpts you can use less.
173 # Adapt to your available RAM to avoid swapping.
174 #
175 # The import will take as little as an hour for a small country extract
176 # and as much as 10 days for a full-scale planet import on less powerful
177 # hardware.
178 #
179 #
180 # Loading Additional Datasets
181 # ---------------------------
182 #
183 # The following commands will create additional entries for countries and POI searches:
184 #
185 #     ./utils/specialphrases.php --countries > data/specialphrases_countries.sql
186 #     psql -d nominatim -f data/specialphrases_countries.sql
187 #     ./utils/specialphrases.php --wiki-import > data/specialphrases.sql
188 #     psql -d nominatim -f data/specialphrases.sql
189