3 # *Note:* these installation instructions are also available in executable
4 # form for use with vagrant under `vagrant/Install-on-Centos-8.sh`.
6 # Installing the Required Software
7 # ================================
9 # These instructions expect that you have a freshly installed CentOS version 8.
10 # Make sure all packages are up-to-date by running:
14 # The standard CentOS repositories don't contain all the required packages,
15 # you need to enable the EPEL repository as well. For example for SELinux
16 # related redhat-hardened-cc1 package. To enable it on CentOS run:
18 sudo dnf install -y epel-release redhat-rpm-config
20 # EPEL contains Postgres 9.6 and 10, but not PostGIS. Postgres 9.4+/10/11/12
21 # and PostGIS 2.4/2.5/3.0 are availble from postgresql.org. Enable these
22 # repositories and make sure, the binaries can be found:
24 sudo dnf -qy module disable postgresql
25 sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
26 export PATH=/usr/pgsql-12/bin:$PATH
28 # Now you can install all packages needed for Nominatim:
31 sudo dnf --enablerepo=powertools install -y postgresql12-server \
32 postgresql12-contrib postgresql12-devel postgis30_12 \
33 wget git cmake make gcc gcc-c++ libtool policycoreutils-python-utils \
34 llvm-toolset ccache clang-tools-extra \
35 php-pgsql php php-intl php-json libpq-devel \
36 bzip2-devel proj-devel boost-devel \
37 python3-pip python3-setuptools python3-devel \
39 expat-devel zlib-devel libicu-devel
41 pip3 install --user python-dotenv psutil Jinja2 PyICU datrie pyyaml
45 # System Configuration
46 # ====================
48 # The following steps are meant to configure a fresh CentOS installation
49 # for use with Nominatim. You may skip some of the steps if you have your
50 # OS already configured.
52 # Creating Dedicated User Accounts
53 # --------------------------------
55 # Nominatim will run as a global service on your machine. It is therefore
56 # best to install it under its own separate user account. In the following
57 # we assume this user is called nominatim and the installation will be in
58 # /srv/nominatim. To create the user and directory run:
60 # sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim
62 # You may find a more suitable location if you wish.
64 # To be able to copy and paste instructions from this manual, export
65 # user name and home directory now like this:
67 if [ "x$USERNAME" == "x" ]; then #DOCS:
68 export USERNAME=vagrant #DOCS: export USERNAME=nominatim
69 export USERHOME=/srv/nominatim
70 sudo mkdir -p /srv/nominatim #DOCS:
71 sudo chown vagrant /srv/nominatim #DOCS:
74 # **Never, ever run the installation as a root user.** You have been warned.
76 # Make sure that system servers can read from the home directory:
80 # Setting up PostgreSQL
81 # ---------------------
83 # CentOS does not automatically create a database cluster. Therefore, start
84 # with initializing the database:
86 if [ "x$NOSYSTEMD" == "xyes" ]; then #DOCS:
87 sudo -u postgres /usr/pgsql-12/bin/pg_ctl initdb -D /var/lib/pgsql/12/data #DOCS:
88 sudo mkdir /var/log/postgresql
89 sudo chown postgres. /var/log/postgresql
91 sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
94 # Next tune the postgresql configuration, which is located in
95 # `/var/lib/pgsql/12/data/postgresql.conf`. See section *Postgres Tuning* in
96 # [the installation page](../admin/Installation.md#postgresql-tuning)
97 # for the parameters to change.
99 # Now start the postgresql service after updating this config file:
101 if [ "x$NOSYSTEMD" == "xyes" ]; then #DOCS:
102 sudo -u postgres /usr/pgsql-12/bin/pg_ctl -D /var/lib/pgsql/12/data -l /var/log/postgresql/postgresql-12.log start #DOCS:
104 sudo systemctl enable postgresql-12
105 sudo systemctl restart postgresql-12
109 # Finally, we need to add two postgres users: one for the user that does
110 # the import and another for the webserver which should access the database
114 sudo -u postgres createuser -s $USERNAME
115 sudo -u postgres createuser apache
118 # Installing Nominatim
119 # ====================
121 # Building and Configuration
122 # --------------------------
124 # Get the source code from Github and change into the source directory
126 if [ "x$1" == "xyes" ]; then #DOCS: :::sh
128 git clone --recursive git://github.com/openstreetmap/Nominatim.git
131 cd $USERHOME/Nominatim #DOCS:
134 # When installing the latest source from github, you also need to
135 # download the country grid:
137 if [ ! -f data/country_osm_grid.sql.gz ]; then #DOCS: :::sh
138 wget --no-verbose -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz
141 # The code must be built in a separate directory. Create this directory,
142 # then configure and build Nominatim in there:
145 mkdir $USERHOME/build
147 cmake $USERHOME/Nominatim
152 # Setting up the Apache Webserver
153 # -------------------------------
155 # The webserver should serve the php scripts from the website directory of your
156 # [project directory](../admin/Import.md#creating-the-project-directory).
157 # This directory needs to exist when the webserver is configured.
158 # Therefore set up a project directory and create the website directory:
160 mkdir $USERHOME/nominatim-project
161 mkdir $USERHOME/nominatim-project/website
163 # You need to create an alias to the website directory in your apache
164 # configuration. Add a separate nominatim configuration to your webserver:
167 sudo tee /etc/httpd/conf.d/nominatim.conf << EOFAPACHECONF
168 <Directory "$USERHOME/nominatim-project/website">
169 Options FollowSymLinks MultiViews
170 AddType text/html .php
171 DirectoryIndex search.php
175 Alias /nominatim $USERHOME/nominatim-project/website
179 sudo sed -i 's:#.*::' /etc/httpd/conf.d/nominatim.conf #DOCS:
182 # Then reload apache:
185 if [ "x$NOSYSTEMD" == "xyes" ]; then #DOCS:
188 sudo systemctl enable httpd
189 sudo systemctl restart httpd
193 # Adding SELinux Security Settings
194 # --------------------------------
196 # It is a good idea to leave SELinux enabled and enforcing, particularly
197 # with a web server accessible from the Internet. At a minimum the
198 # following SELinux labeling should be done for Nominatim:
200 if [ "x$HAVE_SELINUX" != "xno" ]; then #DOCS:
201 sudo semanage fcontext -a -t httpd_sys_content_t "/usr/local/nominatim/lib/lib-php(/.*)?"
202 sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/nominatim-project/website(/.*)?"
203 sudo semanage fcontext -a -t lib_t "$USERHOME/nominatim-project/module/nominatim.so"
204 sudo restorecon -R -v /usr/local/lib/nominatim
205 sudo restorecon -R -v $USERHOME/nominatim-project
208 # You need to create a minimal configuration file that tells nominatim
209 # the name of your webserver user:
212 echo NOMINATIM_DATABASE_WEBUSER="apache" | tee $USERHOME/nominatim-project/.env
216 # Nominatim is now ready to use. Continue with
217 # [importing a database from OSM data](../admin/Import.md).