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
 
  23     sudo dnf -qy module disable postgresql
 
  24     sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
 
  26 # Now you can install all packages needed for Nominatim:
 
  29     sudo dnf --enablerepo=PowerTools install -y postgresql12-server \
 
  30                         postgresql12-contrib postgresql12-devel postgis30_12 \
 
  31                         wget git cmake make gcc gcc-c++ libtool policycoreutils-python-utils \
 
  32                         llvm-toolset ccache clang-tools-extra \
 
  33                         php-pgsql php php-intl php-json libpq-devel \
 
  34                         bzip2-devel proj-devel boost-devel \
 
  35                         python3-pip python3-setuptools python3-devel \
 
  36                         expat-devel zlib-devel
 
  38     pip3 install --user psycopg2
 
  42 # System Configuration
 
  43 # ====================
 
  45 # The following steps are meant to configure a fresh CentOS installation
 
  46 # for use with Nominatim. You may skip some of the steps if you have your
 
  47 # OS already configured.
 
  49 # Creating Dedicated User Accounts
 
  50 # --------------------------------
 
  52 # Nominatim will run as a global service on your machine. It is therefore
 
  53 # best to install it under its own separate user account. In the following
 
  54 # we assume this user is called nominatim and the installation will be in
 
  55 # /srv/nominatim. To create the user and directory run:
 
  57 sudo mkdir -p /srv/nominatim       #DOCS:    sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim
 
  58 sudo chown vagrant /srv/nominatim  #DOCS:
 
  60 # You may find a more suitable location if you wish.
 
  62 # To be able to copy and paste instructions from this manual, export
 
  63 # user name and home directory now like this:
 
  65     export USERNAME=vagrant        #DOCS:    export USERNAME=nominatim
 
  66     export USERHOME=/srv/nominatim
 
  68 # **Never, ever run the installation as a root user.** You have been warned.
 
  70 # Make sure that system servers can read from the home directory:
 
  74 # Setting up PostgreSQL
 
  75 # ---------------------
 
  77 # CentOS does not automatically create a database cluster. Therefore, start
 
  78 # with initializing the database, then enable the server to start at boot:
 
  81     sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
 
  82     sudo systemctl enable postgresql-12
 
  85 # Next tune the postgresql configuration, which is located in 
 
  86 # `/var/lib/pgsql/data/postgresql.conf`. See section *Postgres Tuning* in
 
  87 # [the installation page](../admin/Installation.md#postgresql-tuning)
 
  88 # for the parameters to change.
 
  90 # Now start the postgresql service after updating this config file.
 
  92     sudo systemctl restart postgresql-12
 
  95 # Finally, we need to add two postgres users: one for the user that does
 
  96 # the import and another for the webserver which should access the database
 
 100     sudo -u postgres createuser -s $USERNAME
 
 101     sudo -u postgres createuser apache
 
 104 # Setting up the Apache Webserver
 
 105 # -------------------------------
 
 107 # You need to create an alias to the website directory in your apache
 
 108 # configuration. Add a separate nominatim configuration to your webserver:
 
 111 sudo tee /etc/httpd/conf.d/nominatim.conf << EOFAPACHECONF
 
 112 <Directory "$USERHOME/build/website">
 
 113   Options FollowSymLinks MultiViews
 
 114   AddType text/html   .php
 
 115   DirectoryIndex search.php
 
 119 Alias /nominatim $USERHOME/build/website
 
 123 sudo sed -i 's:#.*::' /etc/httpd/conf.d/nominatim.conf #DOCS:
 
 129     sudo systemctl enable httpd
 
 130     sudo systemctl restart httpd
 
 134 # Installing Nominatim
 
 135 # ====================
 
 137 # Building and Configuration
 
 138 # --------------------------
 
 140 # Get the source code from Github and change into the source directory
 
 142 if [ "x$1" == "xyes" ]; then  #DOCS:    :::sh
 
 144     git clone --recursive git://github.com/openstreetmap/Nominatim.git
 
 147     cd $USERHOME/Nominatim         #DOCS:
 
 150 # When installing the latest source from github, you also need to
 
 151 # download the country grid:
 
 153 if [ ! -f data/country_osm_grid.sql.gz ]; then       #DOCS:    :::sh
 
 154     wget --no-verbose -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz
 
 157 # The code must be built in a separate directory. Create this directory,
 
 158 # then configure and build Nominatim in there:
 
 164     cmake $USERHOME/Nominatim
 
 168 # Adding SELinux Security Settings
 
 169 # --------------------------------
 
 171 # It is a good idea to leave SELinux enabled and enforcing, particularly
 
 172 # with a web server accessible from the Internet. At a minimum the
 
 173 # following SELinux labeling should be done for Nominatim:
 
 175     sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/Nominatim/(website|lib|settings)(/.*)?"
 
 176     sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/build/(website|lib|settings)(/.*)?"
 
 177     sudo semanage fcontext -a -t lib_t "$USERHOME/build/module/nominatim.so"
 
 178     sudo restorecon -R -v $USERHOME/Nominatim
 
 179     sudo restorecon -R -v $USERHOME/build
 
 182 # You need to create a minimal configuration file that tells nominatim
 
 183 # the name of your webserver user:
 
 186 tee settings/local.php << EOF
 
 188  @define('CONST_Database_Web_User', 'apache');
 
 193 # Nominatim is now ready to use. Continue with
 
 194 # [importing a database from OSM data](../admin/Import.md).