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 # !!! danger "Important"
 
  11 #     Ubuntu 20.04 uses Postgresql 12 and Postgis 3, which are known to cause
 
  12 #     performance issues. They are not recommended for a production
 
  13 #     installation at the moment.
 
  15 # *Note:* these installation instructions are also available in executable
 
  16 #         form for use with vagrant under vagrant/Install-on-Ubuntu-20.sh.
 
  18 # Installing the Required Software
 
  19 # ================================
 
  21 # These instructions expect that you have a freshly installed Ubuntu 20.04.
 
  23 # Make sure all packages are are up-to-date by running:
 
  28         -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" \ #DOCS:
 
  29         --allow-downgrades --allow-remove-essential --allow-change-held-packages \ #DOCS:
 
  30         -fuy install grub-pc #DOCS:
 
  31     sudo apt-get update -qq
 
  33 # Now you can install all packages needed for Nominatim:
 
  35     sudo apt-get install -y build-essential cmake g++ libboost-dev libboost-system-dev \
 
  36                             libboost-filesystem-dev libexpat1-dev zlib1g-dev \
 
  37                             libbz2-dev libpq-dev libproj-dev \
 
  38                             postgresql-server-dev-12 postgresql-12-postgis-3 \
 
  39                             postgresql-contrib postgresql-12-postgis-3-scripts \
 
  40                             apache2 php php-pgsql libapache2-mod-php \
 
  41                             php-intl python3-setuptools python3-dev python3-pip \
 
  42                             python3-psycopg2 python3-tidylib git
 
  44 # If you want to run the test suite, you need to install the following
 
  45 # additional packages:
 
  47     sudo apt-get install -y phpunit php-codesniffer php-cgi
 
  49     pip3 install --user behave nose
 
  51 # System Configuration
 
  52 # ====================
 
  54 # The following steps are meant to configure a fresh Ubuntu installation
 
  55 # for use with Nominatim. You may skip some of the steps if you have your
 
  56 # OS already configured.
 
  58 # Creating Dedicated User Accounts
 
  59 # --------------------------------
 
  61 # Nominatim will run as a global service on your machine. It is therefore
 
  62 # best to install it under its own separate user account. In the following
 
  63 # we assume this user is called nominatim and the installation will be in
 
  64 # /srv/nominatim. To create the user and directory run:
 
  66 #     sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim
 
  68 # You may find a more suitable location if you wish.
 
  70 # To be able to copy and paste instructions from this manual, export
 
  71 # user name and home directory now like this:
 
  73     export USERNAME=vagrant        #DOCS:    export USERNAME=nominatim
 
  74     export USERHOME=/home/vagrant  #DOCS:    export USERHOME=/srv/nominatim
 
  76 # **Never, ever run the installation as a root user.** You have been warned.
 
  78 # Make sure that system servers can read from the home directory:
 
  82 # Setting up PostgreSQL
 
  83 # ---------------------
 
  85 # Tune the postgresql configuration, which is located in 
 
  86 # `/etc/postgresql/12/main/postgresql.conf`. See section *Postgres Tuning* in
 
  87 # [the installation page](../admin/Installation.md#postgresql-tuning)
 
  88 # for the parameters to change.
 
  90 # Restart the postgresql service after updating this config file.
 
  92     sudo systemctl restart postgresql
 
  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 www-data
 
 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/apache2/conf-available/nominatim.conf << EOFAPACHECONF
 
 112 <Directory "$USERHOME/build/website"> #DOCS:<Directory "$USERHOME/Nominatim/build/website">
 
 113   Options FollowSymLinks MultiViews
 
 114   AddType text/html   .php
 
 115   DirectoryIndex search.php
 
 119 Alias /nominatim $USERHOME/build/website  #DOCS:Alias /nominatim $USERHOME/Nominatim/build/website
 
 123 sudo sed -i 's:#.*::' /etc/apache2/conf-available/nominatim.conf #DOCS:
 
 126 # Then enable the configuration and restart apache
 
 129     sudo a2enconf nominatim
 
 130     sudo systemctl restart apache2
 
 133 # Installing Nominatim
 
 134 # ====================
 
 136 # Building and Configuration
 
 137 # --------------------------
 
 139 # Get the source code from Github and change into the source directory
 
 141 if [ "x$1" == "xyes" ]; then  #DOCS:    :::sh
 
 143     git clone --recursive git://github.com/openstreetmap/Nominatim.git
 
 146     cd $USERHOME/Nominatim         #DOCS:
 
 149 # When installing the latest source from github, you also need to
 
 150 # download the country grid:
 
 152 if [ ! -f data/country_osm_grid.sql.gz ]; then       #DOCS:    :::sh
 
 153     wget -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz
 
 156 # The code must be built in a separate directory. Create this directory,
 
 157 # then configure and build Nominatim in there:
 
 159     cd $USERHOME                   #DOCS:    :::sh
 
 162     cmake $USERHOME/Nominatim
 
 165 # You need to create a minimal configuration file that tells nominatim
 
 166 # where it is located on the webserver:
 
 169 tee settings/local.php << EOF
 
 171  @define('CONST_Website_BaseURL', '/nominatim/');
 
 176 # Nominatim is now ready to use. Continue with
 
 177 # [importing a database from OSM data](../admin/Import-and-Update.md).