3 # This script sets up a Nominatim installation on a CentOS 7 box.
5 # For more detailed CentOS installation instructions see also
6 # http://wiki.openstreetmap.org/wiki/Nominatim/Installation_on_CentOS
8 ## Part 1: System preparation
10 ## During 'vagrant provision' this script runs as root and the current
11 ## directory is '/root'
15 yum install -y epel-release
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
23 # Create a cluster and start up postgresql.
24 postgresql-setup initdb
25 systemctl enable postgresql
26 systemctl start postgresql
28 # We leave postgresql in its default configuration here. This is only
29 # suitable for small extracts.
31 # Create the necessary postgres users.
32 sudo -u postgres createuser -s vagrant
33 sudo -u postgres createuser apache
35 # Create the website directory.
36 mkdir -m 755 /var/www/html/nominatim
37 chown vagrant /var/www/html/nominatim
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
45 # Configure apache site.
49 # DirectoryIndex index.html
50 # ErrorDocument 403 /index.html
52 DocumentRoot "/var/www/html/"
54 <Directory "/var/www/html/nominatim/">
55 Options FollowSymLinks MultiViews
56 AddType text/html .php
59 ' | sudo tee /etc/httpd/conf.d/nominatim.conf > /dev/null
61 # Restart apache to enable the site configuration.
62 systemctl enable httpd
63 systemctl restart httpd
65 ## Part 2: Nominatim installaion
67 # now ideally login as $USERNAME and continue
70 # If the Nominatim source is not being shared with the host, check out source.
71 if [ ! -d "Nominatim" ]; then
73 sudo -H -u $USERNAME git clone --recursive https://github.com/twain47/Nominatim.git
76 # Configure and compile the source.
78 sudu -u $USERNAME mkdir build-vagrant
80 sudo -u $USERNAME cmake ..
81 sudo -u $USERNAME make
83 # Make sure that postgres has access to the nominatim library.
84 chmod +x /home/$USERNAME
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'
98 @define('CONST_Database_DSN', 'pgsql://@/nominatim');
100 @define('CONST_Postgresql_Version', '9.2');
101 @define('CONST_Postgis_Version', '2.0');
102 @define('CONST_Database_Web_User', 'apache');
104 @define('CONST_Website_BaseURL', 'http://$IP:8089/nominatim/');
105 " > $LOCALSETTINGS_FILE
107 # Install the web interface.
108 sudo -u $USERNAME ./utils/setup.php --create-website /var/www/html/nominatim