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