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 libicu-dev
38 pip3 install --user psycopg2 python-dotenv psutil Jinja2 PyICU
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 # Installing Nominatim
105 # ====================
107 # Building and Configuration
108 # --------------------------
110 # Get the source code from Github and change into the source directory
112 if [ "x$1" == "xyes" ]; then #DOCS: :::sh
114 git clone --recursive git://github.com/openstreetmap/Nominatim.git
117 cd $USERHOME/Nominatim #DOCS:
120 # When installing the latest source from github, you also need to
121 # download the country grid:
123 if [ ! -f data/country_osm_grid.sql.gz ]; then #DOCS: :::sh
124 wget --no-verbose -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz
127 # The code must be built in a separate directory. Create this directory,
128 # then configure and build Nominatim in there:
131 mkdir $USERHOME/build
133 cmake $USERHOME/Nominatim
138 # Setting up the Apache Webserver
139 # -------------------------------
141 # The webserver should serve the php scripts from the website directory of your
142 # [project directory](../admin/import.md#creating-the-project-directory).
143 # Therefore set up a project directory and populate the website directory:
145 mkdir $USERHOME/nominatim-project
146 cd $USERHOME/nominatim-project
147 nominatim refresh --website
149 # You need to create an alias to the website directory in your apache
150 # configuration. Add a separate nominatim configuration to your webserver:
153 sudo tee /etc/httpd/conf.d/nominatim.conf << EOFAPACHECONF
154 <Directory "$USERHOME/nominatim-project/website">
155 Options FollowSymLinks MultiViews
156 AddType text/html .php
157 DirectoryIndex search.php
161 Alias /nominatim $USERHOME/nominatim-project/website
165 sudo sed -i 's:#.*::' /etc/httpd/conf.d/nominatim.conf #DOCS:
171 sudo systemctl enable httpd
172 sudo systemctl restart httpd
175 # Adding SELinux Security Settings
176 # --------------------------------
178 # It is a good idea to leave SELinux enabled and enforcing, particularly
179 # with a web server accessible from the Internet. At a minimum the
180 # following SELinux labeling should be done for Nominatim:
182 sudo semanage fcontext -a -t httpd_sys_content_t "/usr/local/nominatim/lib/lib-php(/.*)?"
183 sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/nominatim-project/website(/.*)?"
184 sudo semanage fcontext -a -t lib_t "$USERHOME/nominatim-project/module/nominatim.so"
185 sudo restorecon -R -v /usr/local/lib/nominatim
186 sudo restorecon -R -v $USERHOME/nominatim-project
189 # You need to create a minimal configuration file that tells nominatim
190 # the name of your webserver user:
193 echo NOMINATIM_DATABASE_WEBUSER="apache" | tee .env
197 # Nominatim is now ready to use. Continue with
198 # [importing a database from OSM data](../admin/Import.md).