]> git.openstreetmap.org Git - nominatim.git/blob - vagrant/centos-7-provision.sh
fix nominatim paths
[nominatim.git] / vagrant / centos-7-provision.sh
1 #!/bin/bash
2
3 # This script sets up a Nominatim installation on a CentOS 7 box.
4 #
5 # For more detailed CentOS installation instructions see also
6 # http://wiki.openstreetmap.org/wiki/Nominatim/Installation_on_CentOS
7
8 ## Part 1: System preparation
9
10 ## During 'vagrant provision' this script runs as root and the current
11 ## directory is '/root'
12 USERNAME=vagrant
13
14 yum update -y
15 yum install -y epel-release
16
17 yum install -y postgresql-server postgresql-contrib postgresql-devel postgis postgis-utils \
18                make cmake gcc gcc-c++ libtool policycoreutils-python \
19                php-pgsql php php-pear php-pear-DB libpqxx-devel proj-epsg \
20                bzip2-devel proj-devel geos-devel libxml2-devel boost-devel \
21                expat-devel zlib-devel
22
23 # Create a cluster and start up postgresql.
24 postgresql-setup initdb
25 systemctl enable postgresql
26 systemctl start postgresql
27
28 # We leave postgresql in its default configuration here. This is only
29 # suitable for small extracts.
30
31 # Create the necessary postgres users.
32 sudo -u postgres createuser -s vagrant
33 sudo -u postgres createuser apache
34
35 # Create the website directory.
36 mkdir -m 755 /var/www/html/nominatim
37 chown vagrant /var/www/html/nominatim
38
39 # Set up the necessary rights on SELinux.
40 semanage fcontext -a -t httpd_sys_content_t "/home/vagrant/Nominatim/(website|lib|settings)(/.*)?"
41 semanage fcontext -a -t lib_t "/home/vagrant/Nominatim/module/nominatim.so"
42 semanage port -a -t http_port_t -p tcp 8089
43 restorecon -R -v /home/vagrant/Nominatim
44
45 # Configure apache site.
46 echo '
47 Listen 8089
48 <VirtualHost *:8089>
49     # DirectoryIndex index.html
50     # ErrorDocument 403 /index.html
51
52     DocumentRoot "/var/www/html/"
53  
54     <Directory "/var/www/html/nominatim/">
55       Options FollowSymLinks MultiViews
56       AddType text/html   .php
57     </Directory>
58 </VirtualHost>
59 ' | sudo tee /etc/httpd/conf.d/nominatim.conf > /dev/null
60
61 # Restart apache to enable the site configuration.
62 systemctl enable httpd
63 systemctl restart httpd
64
65 ## Part 2: Nominatim installaion
66
67 # now ideally login as $USERNAME and continue
68 cd /home/$USERNAME
69
70 # If the Nominatim source is not being shared with the host, check out source.
71 if [ ! -d "Nominatim" ]; then
72   yum install -y git
73   sudo -H -u $USERNAME git clone --recursive https://github.com/twain47/Nominatim.git
74 fi
75
76 # Configure and compile the source.
77 cd Nominatim
78 sudu -u $USERNAME mkdir build-vagrant
79 cd build-vagrant
80 sudo -u $USERNAME cmake ..
81 sudo -u $USERNAME make
82
83 # Make sure that postgres has access to the nominatim library.
84 chmod +x /home/$USERNAME
85 chmod +x ./
86 chmod +x ./module
87
88 # Create customized settings suitable for this VM installation.
89 LOCALSETTINGS_FILE='settings/local.php'
90 if [[ -e "$LOCALSETTINGS_FILE" ]]; then
91   echo "$LOCALSETTINGS_FILE already exist, writing to settings/local-vagrant.php instead."
92   LOCALSETTINGS_FILE='settings/local-vagrant.php'
93 fi
94
95 IP=localhost
96 echo "<?php
97    // General settings
98    @define('CONST_Database_DSN', 'pgsql://@/nominatim');
99    // Paths
100    @define('CONST_Postgresql_Version', '9.2');
101    @define('CONST_Postgis_Version', '2.0');
102    @define('CONST_Database_Web_User', 'apache');
103    // Website settings
104    @define('CONST_Website_BaseURL', 'http://$IP:8089/nominatim/');
105 " > $LOCALSETTINGS_FILE
106
107 # Install the web interface.
108 sudo -u $USERNAME ./utils/setup.php --create-website /var/www/html/nominatim