]> git.openstreetmap.org Git - nominatim.git/blob - vagrant/install-on-centos-7.sh
Merge pull request #613 from mtmail/travis-behave-and-split-tests
[nominatim.git] / vagrant / install-on-centos-7.sh
1 #!/bin/bash
2 #
3 # *Note:* these installation instructions are also available in executable
4 #         form for use with vagrant under vagrant/install-on-centos-7.sh.
5 #
6 # Installing the Required Software
7 # ================================
8 #
9 # These instructions expect that you have a freshly installed CentOS version 7.
10 # Make sure all packages are are up-to-date by running:
11 #
12     sudo yum update -y
13
14 # The standard CentOS repositories don't contain all the required packages,
15 # you need to enable the EPEL repository as well. To enable it on CentOS,
16 # install the epel-release RPM by running:
17
18     sudo yum install -y epel-release
19
20 # Now you can install all packages needed for Nominatim:
21
22     sudo yum install -y postgresql-server postgresql-contrib postgresql-devel postgis postgis-utils \
23                         git cmake make gcc gcc-c++ libtool policycoreutils-python \
24                         php-pgsql php php-pear php-pear-DB libpqxx-devel proj-epsg \
25                         bzip2-devel proj-devel geos-devel libxml2-devel boost-devel expat-devel zlib-devel
26
27 # If you want to run the test suite, you need to install the following
28 # additional packages:
29
30     sudo yum install -y python-pip python-Levenshtein python-psycopg2 \
31                         python-numpy php-phpunit-PHPUnit
32     pip install --user --upgrade pip setuptools lettuce==0.2.18 six==1.9 \
33                                  haversine Shapely pytidylib
34     sudo pear install PHP_CodeSniffer
35
36 #
37 # System Configuration
38 # ====================
39 #
40 # The following steps are meant to configure a fresh CentOS installation
41 # for use with Nominatim. You may skip some of the steps if you have your
42 # OS already configured.
43 #
44 # Creating Dedicated User Accounts
45 # --------------------------------
46 #
47 # Nominatim will run as a global service on your machine. It is therefore
48 # best to install it under its own separate user account. In the following
49 # we assume this user is called nominatim and the installation will be in
50 # /srv/nominatim. To create the user and directory run:
51 #
52 #     sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim
53 #
54 # You may find a more suitable location if you wish.
55 #
56 # To be able to copy and paste instructions from this manual, export
57 # user name and home directory now like this:
58 #
59     export USERNAME=vagrant        #DOCS:    export USERNAME=nominatim
60     export USERHOME=/home/vagrant  #DOCS:    export USERHOME=/srv/nominatim
61 #
62 # **Never, ever run the installation as a root user.** You have been warned.
63 #
64 # Make sure that system servers can read from the home directory:
65
66     chmod a+x $USERHOME
67
68 # Setting up PostgreSQL
69 # ---------------------
70 #
71 # CentOS does not automatically create a database cluster. Therefore, start
72 # with initializing the database, then enable the server to start at boot:
73
74     sudo postgresql-setup initdb
75     sudo systemctl enable postgresql
76
77 #
78 # Next tune the postgresql configuration, which is located in 
79 # `/var/lib/pgsql/data/postgresql.conf`. See section *Postgres Tuning* in
80 # [the installation page](Installation.md) for the parameters to change.
81 #
82 # Now start the postgresql service after updating this config file.
83
84     sudo systemctl restart postgresql
85
86 #
87 # Finally, we need to add two postgres users: one for the user that does
88 # the import and another for the webserver which should access the database
89 # only for reading:
90 #
91
92     sudo -u postgres createuser -s $USERNAME
93     sudo -u postgres createuser apache
94
95 #
96 # Setting up the Apache Webserver
97 # -------------------------------
98 #
99 # You need to create an alias to the website directory in your apache
100 # configuration. Add a separate nominatim configuration to your webserver:
101
102 #DOCS:```
103 sudo tee /etc/httpd/conf.d/nominatim.conf << EOFAPACHECONF
104 <Directory "$USERHOME/build/website"> #DOCS:<Directory "$USERHOME/Nominatim/build/website">
105   Options FollowSymLinks MultiViews
106   AddType text/html   .php
107   DirectoryIndex search.php
108   Require all granted
109 </Directory>
110
111 Alias /nominatim $USERHOME/build/website  #DOCS:Alias /nominatim $USERHOME/Nominatim/build/website
112 EOFAPACHECONF
113 #DOCS:```
114
115 sudo sed -i 's:#.*::' /etc/httpd/conf.d/nominatim.conf #DOCS:
116
117 #
118 # Then reload apache
119 #
120
121     sudo systemctl restart httpd
122
123 #
124 # Adding SELinux Security Settings
125 # --------------------------------
126 #
127 # It is a good idea to leave SELinux enabled and enforcing, particularly
128 # with a web server accessible from the Internet. At a minimum the
129 # following SELinux labeling should be done for Nominatim:
130
131     sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/Nominatim/(website|lib|settings)(/.*)?"
132     sudo semanage fcontext -a -t lib_t "$USERHOME/Nominatim/module/nominatim.so"
133     sudo restorecon -R -v $USERHOME/Nominatim
134
135 #
136 # Installing Nominatim
137 # ====================
138 #
139 # Building and Configuration
140 # --------------------------
141 #
142 # Get the source code from Github and change into the source directory
143 #
144 if [ "x$1" == "xyes" ]; then  #DOCS:
145
146     cd $USERHOME
147     git clone --recursive git://github.com/twain47/Nominatim.git
148 #DOCS:    cd Nominatim
149
150 else                               #DOCS:
151     cd $USERHOME                   #DOCS:
152 fi                                 #DOCS:
153
154 # The code must be built in a separate directory. Create this directory,
155 # then configure and build Nominatim in there:
156
157     mkdir build
158     cd build
159     cmake $USERHOME/Nominatim
160     make
161
162 # You need to create a minimal configuration file that tells nominatim
163 # the name of your webserver user and the URL of the website:
164
165 #DOCS:```
166 tee settings/local.php << EOF
167 <?php
168  @define('CONST_Database_Web_User', 'apache');
169  @define('CONST_Website_BaseURL', '/nominatim/');
170 EOF
171 #DOCS:```
172
173
174 # Nominatim is now ready to use. Continue with
175 # [importing a database from OSM data](Import_and_update.md).