3 # hacks for broken vagrant box #DOCS:
4 sudo rm -f /var/lib/dpkg/lock #DOCS:
5 sudo update-locale LANG=en_US.UTF-8 #DOCS:
6 export APT_LISTCHANGES_FRONTEND=none #DOCS:
7 export DEBIAN_FRONTEND=noninteractive #DOCS:
10 # *Note:* these installation instructions are also available in executable
11 # form for use with vagrant under vagrant/Install-on-Ubuntu-18.sh.
13 # Installing the Required Software
14 # ================================
16 # These instructions expect that you have a freshly installed Ubuntu 18.04.
18 # Make sure all packages are are up-to-date by running:
21 sudo apt-get -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" --force-yes -fuy install grub-pc #DOCS:
24 # Now you can install all packages needed for Nominatim:
26 sudo apt install -y php-cgi
27 sudo apt install -y build-essential cmake g++ libboost-dev libboost-system-dev \
28 libboost-filesystem-dev libexpat1-dev zlib1g-dev\
29 libbz2-dev libpq-dev libproj-dev \
30 postgresql-server-dev-10 postgresql-10-postgis-2.4 \
31 postgresql-contrib-10 postgresql-10-postgis-scripts \
32 php php-pgsql php-intl libicu-dev python3-pip \
33 python3-psycopg2 python3-psutil python3-jinja2 python3-icu git
35 # The python-dotenv package that comes with Ubuntu 18.04 is too old, so
36 # install the latest version from pip:
38 pip3 install python-dotenv
41 # System Configuration
42 # ====================
44 # The following steps are meant to configure a fresh Ubuntu installation
45 # for use with Nominatim. You may skip some of the steps if you have your
46 # OS already configured.
48 # Creating Dedicated User Accounts
49 # --------------------------------
51 # Nominatim will run as a global service on your machine. It is therefore
52 # best to install it under its own separate user account. In the following
53 # we assume this user is called nominatim and the installation will be in
54 # /srv/nominatim. To create the user and directory run:
56 # sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim
58 # You may find a more suitable location if you wish.
60 # To be able to copy and paste instructions from this manual, export
61 # user name and home directory now like this:
63 export USERNAME=vagrant #DOCS: export USERNAME=nominatim
64 export USERHOME=/home/vagrant #DOCS: export USERHOME=/srv/nominatim
66 # **Never, ever run the installation as a root user.** You have been warned.
68 # Make sure that system servers can read from the home directory:
72 # Setting up PostgreSQL
73 # ---------------------
75 # Tune the postgresql configuration, which is located in
76 # `/etc/postgresql/10/main/postgresql.conf`. See section *Postgres Tuning* in
77 # [the installation page](../admin/Installation.md#postgresql-tuning)
78 # for the parameters to change.
80 # Restart the postgresql service after updating this config file.
82 sudo systemctl restart postgresql
85 # Finally, we need to add two postgres users: one for the user that does
86 # the import and another for the webserver which should access the database
90 sudo -u postgres createuser -s $USERNAME
91 sudo -u postgres createuser www-data
94 # Installing Nominatim
95 # ====================
97 # Building and Configuration
98 # --------------------------
100 # Get the source code from Github and change into the source directory
102 if [ "x$1" == "xyes" ]; then #DOCS: :::sh
104 git clone --recursive git://github.com/openstreetmap/Nominatim.git
107 cd $USERHOME/Nominatim #DOCS:
110 # When installing the latest source from github, you also need to
111 # download the country grid:
113 if [ ! -f data/country_osm_grid.sql.gz ]; then #DOCS: :::sh
114 wget -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz
117 # The code must be built in a separate directory. Create this directory,
118 # then configure and build Nominatim in there:
120 mkdir $USERHOME/build
122 cmake $USERHOME/Nominatim
127 # Nominatim is now ready to use. You can continue with
128 # [importing a database from OSM data](../admin/Import.md). If you want to set up
129 # a webserver first, continue reading.
131 # Setting up a webserver
132 # ======================
134 # The webserver should serve the php scripts from the website directory of your
135 # [project directory](../admin/import.md#creating-the-project-directory).
136 # Therefore set up a project directory and populate the website directory:
138 mkdir $USERHOME/nominatim-project
139 cd $USERHOME/nominatim-project
140 nominatim refresh --website
142 # Option 1: Using Apache
143 # ----------------------
145 if [ "x$2" == "xinstall-apache" ]; then #DOCS:
147 # Apache has a PHP module that can be used to serve Nominatim. To install them
150 sudo apt install -y apache2 libapache2-mod-php
152 # You need to create an alias to the website directory in your apache
153 # configuration. Add a separate nominatim configuration to your webserver:
156 sudo tee /etc/apache2/conf-available/nominatim.conf << EOFAPACHECONF
157 <Directory "$USERHOME/nominatim-project/website">
158 Options FollowSymLinks MultiViews
159 AddType text/html .php
160 DirectoryIndex search.php
164 Alias /nominatim $USERHOME/nominatim-project/website
169 # Then enable the configuration and restart apache
172 sudo a2enconf nominatim
173 sudo systemctl restart apache2
175 # The Nominatim API is now available at `http://localhost/nominatim/`.
180 # Option 2: Using nginx
181 # ---------------------
183 if [ "x$2" == "xinstall-nginx" ]; then #DOCS:
185 # Nginx has no native support for php scripts. You need to set up php-fpm for
186 # this purpose. First install nginx and php-fpm:
188 sudo apt install -y nginx php-fpm
190 # You need to configure php-fpm to listen on a Unix socket.
193 sudo tee /etc/php/7.2/fpm/pool.d/www.conf << EOF_PHP_FPM_CONF
195 ; Replace the tcp listener and add the unix socket
196 listen = /var/run/php7.2-fpm.sock
198 ; Ensure that the daemon runs as the correct user
199 listen.owner = www-data
200 listen.group = www-data
203 ; Unix user of FPM processes
207 ; Choose process manager type (static, dynamic, ondemand)
213 # Then create a Nginx configuration to forward http requests to that socket.
216 sudo tee /etc/nginx/sites-available/default << EOF_NGINX_CONF
218 listen 80 default_server;
219 listen [::]:80 default_server;
221 root $USERHOME/nominatim-project/website;
222 index search.php index.html;
224 try_files \$uri \$uri/ @php;
228 fastcgi_param SCRIPT_FILENAME "\$document_root\$uri.php";
229 fastcgi_param PATH_TRANSLATED "\$document_root\$uri.php";
230 fastcgi_param QUERY_STRING \$args;
231 fastcgi_pass unix:/var/run/php7.2-fpm.sock;
232 fastcgi_index index.php;
233 include fastcgi_params;
236 location ~ [^/]\.php(/|$) {
237 fastcgi_split_path_info ^(.+?\.php)(/.*)$;
238 if (!-f \$document_root\$fastcgi_script_name) {
241 fastcgi_pass unix:/var/run/php7.2-fpm.sock;
242 fastcgi_index search.php;
243 include fastcgi.conf;
250 # Enable the configuration and restart Nginx
253 sudo systemctl restart php7.2-fpm nginx
255 # The Nominatim API is now available at `http://localhost/`.