]> git.openstreetmap.org Git - nominatim.git/blob - vagrant/Install-on-Ubuntu-18-nginx.sh
README: tiny markdown syntax error
[nominatim.git] / vagrant / Install-on-Ubuntu-18-nginx.sh
1 #!/bin/bash
2
3 #
4 # This is variation of Install-on-Ubuntu.sh showcasing how to use the
5 # nginx webserver instead of Apache2. We might eventually merge both
6 # files. Right now expect this file to become outdated/unmaintained
7 # over time.
8 #
9 # This file lacks many comments found in Install-on-Ubuntu.sh, you
10 # should check that file first to get a basic understanding.
11 #
12
13 # hacks for broken vagrant box
14 sudo rm -f /var/lib/dpkg/lock
15 sudo update-locale LANG=en_US.UTF-8
16 export APT_LISTCHANGES_FRONTEND=none
17 export DEBIAN_FRONTEND=noninteractive
18
19     sudo apt-get update -qq
20     sudo apt-get install -y build-essential cmake g++ libboost-dev libboost-system-dev \
21                             libboost-filesystem-dev libexpat1-dev zlib1g-dev libxml2-dev\
22                             libbz2-dev libpq-dev libproj-dev \
23                             postgresql-server-dev-10 postgresql-10-postgis-2.4 \
24                             postgresql-contrib-10 \
25                             nginx php-fpm php php-pgsql php-pear php-db \
26                             php-intl git
27
28     export USERNAME=vagrant
29     export USERHOME=/home/vagrant
30
31     chmod a+x $USERHOME
32
33 # Setting up PostgreSQL
34 # ---------------------
35 #
36 # Tune the postgresql configuration, see same section in Install-on-Ubuntu.sh
37
38     sudo systemctl restart postgresql
39
40     sudo -u postgres createuser -s $USERNAME
41     sudo -u postgres createuser www-data
42
43 #
44 # Setting up the Nginx Webserver
45 # -------------------------------
46 #
47 # You need to configure php-fpm to listen on a Unix socket. Then create Nginx
48 # configuration to forward localhost:80 requests to that socket.
49 #
50
51
52 sudo tee /etc/php/7.2/fpm/pool.d/www.conf << EOF_PHP_FPM_CONF
53 [www]
54 ; Comment out the tcp listener and add the unix socket
55 ;listen = 127.0.0.1:9000
56 listen = /var/run/php7.2-fpm.sock
57
58 ; Ensure that the daemon runs as the correct user
59 listen.owner = www-data
60 listen.group = www-data
61 listen.mode = 0666
62
63 ; Unix user of FPM processes
64 user = www-data
65 group = www-data
66
67 ; Choose process manager type (static, dynamic, ondemand)
68 pm = ondemand
69 pm.max_children = 5
70 EOF_PHP_FPM_CONF
71
72
73
74
75 sudo tee /etc/nginx/sites-available/default << EOF_NGINX_CONF
76 server {
77     listen 80 default_server;
78     listen [::]:80 default_server;
79
80     root $USERHOME/build/website;
81     index search.php index.html;
82     location / {
83         try_files \$uri \$uri/ @php;
84     }
85
86     location @php {
87         fastcgi_param SCRIPT_FILENAME "\$document_root\$uri.php";
88         fastcgi_param PATH_TRANSLATED "\$document_root\$uri.php";
89         fastcgi_param QUERY_STRING    \$args;
90         fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
91         fastcgi_index index.php;
92         include fastcgi_params;
93     }
94
95     location ~ [^/]\.php(/|$) {
96         fastcgi_split_path_info ^(.+?\.php)(/.*)$;
97         if (!-f \$document_root\$fastcgi_script_name) {
98             return 404;
99         }
100         fastcgi_pass unix:/var/run/php7.2-fpm.sock;
101         fastcgi_index search.php;
102         include fastcgi.conf;
103     }
104 }
105 EOF_NGINX_CONF
106
107
108 sudo sed -i 's:#.*::' /etc/nginx/sites-available/default
109
110
111 #
112 # Enable the configuration and restart Nginx
113 #
114
115     sudo systemctl stop apache2 # just in case it's installed as well
116     sudo systemctl restart php7.2-fpm nginx
117
118 # From here continue in the 'Installing Nominatim' section in
119 # Install-on-Ubuntu.sh
120