]> git.openstreetmap.org Git - nominatim.git/blob - vagrant/Install-on-Ubuntu-18.sh
add vagrant and installation instructions for ubuntu 18
[nominatim.git] / vagrant / Install-on-Ubuntu-18.sh
1 #!/bin/bash
2 #
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:
8
9 #
10 # *Note:* these installation instructions are also available in executable
11 #         form for use with vagrant under vagrant/Install-on-Ubuntu-18.sh.
12 #
13 # Installing the Required Software
14 # ================================
15 #
16 # These instructions expect that you have a freshly installed Ubuntu 18.04.
17 #
18 # Make sure all packages are are up-to-date by running:
19 #
20
21 #DOCS:    :::sh
22     sudo apt-get -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" --force-yes -fuy install grub-pc #DOCS:
23     sudo apt-get update -qq
24
25 # Now you can install all packages needed for Nominatim:
26
27     sudo apt-get install -y build-essential cmake g++ libboost-dev libboost-system-dev \
28                             libboost-filesystem-dev libexpat1-dev zlib1g-dev libxml2-dev\
29                             libbz2-dev libpq-dev libproj-dev \
30                             postgresql-server-dev-10 postgresql-10-postgis-2.4 \
31                             postgresql-contrib-10 \
32                             apache2 php php-pgsql libapache2-mod-php php-pear php-db \
33                             php-intl git
34
35 # If you want to run the test suite, you need to install the following
36 # additional packages:
37
38     sudo apt-get install -y python3-setuptools python3-dev python3-pip \
39                             python3-psycopg2 python3-tidylib phpunit php-cgi
40
41     pip3 install --user behave nose
42     sudo pear install PHP_CodeSniffer
43
44 #
45 # System Configuration
46 # ====================
47 #
48 # The following steps are meant to configure a fresh Ubuntu installation
49 # for use with Nominatim. You may skip some of the steps if you have your
50 # OS already configured.
51 #
52 # Creating Dedicated User Accounts
53 # --------------------------------
54 #
55 # Nominatim will run as a global service on your machine. It is therefore
56 # best to install it under its own separate user account. In the following
57 # we assume this user is called nominatim and the installation will be in
58 # /srv/nominatim. To create the user and directory run:
59 #
60 #     sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim
61 #
62 # You may find a more suitable location if you wish.
63 #
64 # To be able to copy and paste instructions from this manual, export
65 # user name and home directory now like this:
66 #
67     export USERNAME=vagrant        #DOCS:    export USERNAME=nominatim
68     export USERHOME=/home/vagrant  #DOCS:    export USERHOME=/srv/nominatim
69 #
70 # **Never, ever run the installation as a root user.** You have been warned.
71 #
72 # Make sure that system servers can read from the home directory:
73
74     chmod a+x $USERHOME
75
76 # Setting up PostgreSQL
77 # ---------------------
78 #
79 # Tune the postgresql configuration, which is located in 
80 # `/etc/postgresql/9.5/main/postgresql.conf`. See section *Postgres Tuning* in
81 # [the installation page](../admin/Installation.md#postgresql-tuning)
82 # for the parameters to change.
83 #
84 # Restart the postgresql service after updating this config file.
85
86     sudo systemctl restart postgresql
87
88 #
89 # Finally, we need to add two postgres users: one for the user that does
90 # the import and another for the webserver which should access the database
91 # for reading only:
92 #
93
94     sudo -u postgres createuser -s $USERNAME
95     sudo -u postgres createuser www-data
96
97 #
98 # Setting up the Apache Webserver
99 # -------------------------------
100 #
101 # You need to create an alias to the website directory in your apache
102 # configuration. Add a separate nominatim configuration to your webserver:
103
104 #DOCS:```sh
105 sudo tee /etc/apache2/conf-available/nominatim.conf << EOFAPACHECONF
106 <Directory "$USERHOME/build/website"> #DOCS:<Directory "$USERHOME/Nominatim/build/website">
107   Options FollowSymLinks MultiViews
108   AddType text/html   .php
109   DirectoryIndex search.php
110   Require all granted
111 </Directory>
112
113 Alias /nominatim $USERHOME/build/website  #DOCS:Alias /nominatim $USERHOME/Nominatim/build/website
114 EOFAPACHECONF
115 #DOCS:```
116
117 sudo sed -i 's:#.*::' /etc/apache2/conf-available/nominatim.conf #DOCS:
118
119 #
120 # Then enable the configuration and restart apache
121 #
122
123     sudo a2enconf nominatim
124     sudo systemctl restart apache2
125
126 #
127 # Installing Nominatim
128 # ====================
129 #
130 # Building and Configuration
131 # --------------------------
132 #
133 # Get the source code from Github and change into the source directory
134 #
135 if [ "x$1" == "xyes" ]; then  #DOCS:    :::sh
136     cd $USERHOME
137     git clone --recursive git://github.com/openstreetmap/Nominatim.git
138     cd Nominatim
139 else                               #DOCS:
140     cd $USERHOME/Nominatim         #DOCS:
141 fi                                 #DOCS:
142
143 # When installing the latest source from github, you also need to
144 # download the country grid:
145
146 if [ ! -f data/country_osm_grid.sql.gz ]; then       #DOCS:    :::sh
147     wget -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz
148 fi                                 #DOCS:
149
150 # The code must be built in a separate directory. Create this directory,
151 # then configure and build Nominatim in there:
152
153     cd $USERHOME                   #DOCS:    :::sh
154     mkdir build
155     cd build
156     cmake $USERHOME/Nominatim
157     make
158
159 # You need to create a minimal configuration file that tells nominatim
160 # where it is located on the webserver:
161
162 #DOCS:```sh
163 tee settings/local.php << EOF
164 <?php
165  @define('CONST_Website_BaseURL', '/nominatim/');
166 EOF
167 #DOCS:```
168
169
170 # Nominatim is now ready to use. Continue with
171 # [importing a database from OSM data](../admin/Import-and-Update.md).