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