3 # *Note:* these installation instructions are also available in executable
4 # form for use with vagrant under `vagrant/Install-on-Centos-7.sh`.
6 # Installing the Required Software
7 # ================================
9 # These instructions expect that you have a freshly installed CentOS version 7.
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. To enable it on CentOS,
16 # install the epel-release RPM by running:
18 sudo yum install -y epel-release
20 # More repositories for postgresql 11 (CentOS default 'postgresql' is 9.2), postgis
21 # and llvm-toolset (https://github.com/theory/pg-semver/issues/35)
23 sudo yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
24 sudo yum install -y centos-release-scl-rh
26 # Now you can install all packages needed for Nominatim:
30 sudo yum install -y postgresql11-server postgresql11-contrib postgresql11-devel \
31 postgis25_11 postgis25_11-utils \
32 wget git cmake make gcc gcc-c++ libtool policycoreutils-python \
33 devtoolset-7 llvm-toolset-7 \
34 php-pgsql php php-intl libpqxx-devel \
35 proj-epsg bzip2-devel proj-devel boost-devel \
36 expat-devel zlib-devel
38 # make sure pg_config gets found
39 echo 'PATH=/usr/pgsql-11/bin/$PATH' >> ~/.bash_profile
40 source ~/.bash_profile
42 # If you want to run the test suite, you need to install the following
43 # additional packages:
46 sudo yum install -y python34-pip python34-setuptools python34-devel \
48 pip3 install --user behave nose pytidylib psycopg2
50 composer global require "squizlabs/php_codesniffer=*"
51 sudo ln -s ~/.config/composer/vendor/bin/phpcs /usr/bin/
54 # System Configuration
55 # ====================
57 # The following steps are meant to configure a fresh CentOS installation
58 # for use with Nominatim. You may skip some of the steps if you have your
59 # OS already configured.
61 # Creating Dedicated User Accounts
62 # --------------------------------
64 # Nominatim will run as a global service on your machine. It is therefore
65 # best to install it under its own separate user account. In the following
66 # we assume this user is called nominatim and the installation will be in
67 # /srv/nominatim. To create the user and directory run:
69 sudo mkdir -p /srv/nominatim #DOCS: sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim
70 sudo chown vagrant /srv/nominatim #DOCS:
72 # You may find a more suitable location if you wish.
74 # To be able to copy and paste instructions from this manual, export
75 # user name and home directory now like this:
77 export USERNAME=vagrant #DOCS: export USERNAME=nominatim
78 export USERHOME=/srv/nominatim
80 # **Never, ever run the installation as a root user.** You have been warned.
82 # Make sure that system servers can read from the home directory:
86 # Setting up PostgreSQL
87 # ---------------------
89 # CentOS does not automatically create a database cluster. Therefore, start
90 # with initializing the database, then enable the server to start at boot:
92 sudo /usr/pgsql-11/bin/postgresql-11-setup initdb
93 sudo systemctl enable postgresql-11
96 # Next tune the postgresql configuration, which is located in
97 # `/var/lib/pgsql/data/postgresql.conf`. See section *Postgres Tuning* in
98 # [the installation page](../admin/Installation.md#postgresql-tuning)
99 # for the parameters to change.
101 # Now start the postgresql service after updating this config file.
103 sudo systemctl restart postgresql-11
106 # Finally, we need to add two postgres users: one for the user that does
107 # the import and another for the webserver which should access the database
111 sudo -u postgres createuser -s $USERNAME
112 sudo -u postgres createuser apache
115 # Setting up the Apache Webserver
116 # -------------------------------
118 # You need to create an alias to the website directory in your apache
119 # configuration. Add a separate nominatim configuration to your webserver:
122 sudo tee /etc/httpd/conf.d/nominatim.conf << EOFAPACHECONF
123 <Directory "$USERHOME/build/website">
124 Options FollowSymLinks MultiViews
125 AddType text/html .php
126 DirectoryIndex search.php
130 Alias /nominatim $USERHOME/build/website
134 sudo sed -i 's:#.*::' /etc/httpd/conf.d/nominatim.conf #DOCS:
140 sudo systemctl enable httpd
141 sudo systemctl restart httpd
145 # Installing Nominatim
146 # ====================
148 # Building and Configuration
149 # --------------------------
151 # Get the source code from Github and change into the source directory
153 if [ "x$1" == "xyes" ]; then #DOCS: :::sh
155 git clone --recursive git://github.com/openstreetmap/Nominatim.git
158 cd $USERHOME/Nominatim #DOCS:
161 # When installing the latest source from github, you also need to
162 # download the country grid:
164 if [ ! -f data/country_osm_grid.sql.gz ]; then #DOCS: :::sh
165 wget --no-verbose -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz
168 # The code must be built in a separate directory. Create this directory,
169 # then configure and build Nominatim in there:
175 cmake $USERHOME/Nominatim
179 # Adding SELinux Security Settings
180 # --------------------------------
182 # It is a good idea to leave SELinux enabled and enforcing, particularly
183 # with a web server accessible from the Internet. At a minimum the
184 # following SELinux labeling should be done for Nominatim:
186 sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/Nominatim/(website|lib|settings)(/.*)?"
187 sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/build/(website|lib|settings)(/.*)?"
188 sudo semanage fcontext -a -t lib_t "$USERHOME/build/module/nominatim.so"
189 sudo restorecon -R -v $USERHOME/Nominatim
190 sudo restorecon -R -v $USERHOME/build
193 # You need to create a minimal configuration file that tells nominatim
194 # the name of your webserver user and the URL of the website:
197 tee settings/local.php << EOF
199 @define('CONST_Database_Web_User', 'apache');
200 @define('CONST_Website_BaseURL', '/nominatim/');
205 # Nominatim is now ready to use. Continue with
206 # [importing a database from OSM data](../admin/Import-and-Update.md).