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
 
   9 # This file lacks many comments found in Install-on-Ubuntu.sh, you
 
  10 # should check that file first to get a basic understanding.
 
  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
 
  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\
 
  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 \
 
  26                             php-intl python3-setuptools python3-dev python3-pip \
 
  27                             python3-psycopg2 python3-tidylib git
 
  29     export USERNAME=vagrant
 
  30     export USERHOME=/home/vagrant
 
  34 # Setting up PostgreSQL
 
  35 # ---------------------
 
  37 # Tune the postgresql configuration, see same section in Install-on-Ubuntu.sh
 
  39     sudo systemctl restart postgresql
 
  41     sudo -u postgres createuser -s $USERNAME
 
  42     sudo -u postgres createuser www-data
 
  45 # Setting up the Nginx Webserver
 
  46 # -------------------------------
 
  48 # You need to configure php-fpm to listen on a Unix socket. Then create Nginx
 
  49 # configuration to forward localhost:80 requests to that socket.
 
  53 sudo tee /etc/php/7.2/fpm/pool.d/www.conf << EOF_PHP_FPM_CONF
 
  55 ; Comment out the tcp listener and add the unix socket
 
  56 ;listen = 127.0.0.1:9000
 
  57 listen = /var/run/php7.2-fpm.sock
 
  59 ; Ensure that the daemon runs as the correct user
 
  60 listen.owner = www-data
 
  61 listen.group = www-data
 
  64 ; Unix user of FPM processes
 
  68 ; Choose process manager type (static, dynamic, ondemand)
 
  76 sudo tee /etc/nginx/sites-available/default << EOF_NGINX_CONF
 
  78     listen 80 default_server;
 
  79     listen [::]:80 default_server;
 
  81     root $USERHOME/build/website;
 
  82     index search.php index.html;
 
  84         try_files \$uri \$uri/ @php;
 
  88         fastcgi_param SCRIPT_FILENAME "\$document_root\$uri.php";
 
  89         fastcgi_param PATH_TRANSLATED "\$document_root\$uri.php";
 
  90         fastcgi_param QUERY_STRING    \$args;
 
  91         fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
 
  92         fastcgi_index index.php;
 
  93         include fastcgi_params;
 
  96     location ~ [^/]\.php(/|$) {
 
  97         fastcgi_split_path_info ^(.+?\.php)(/.*)$;
 
  98         if (!-f \$document_root\$fastcgi_script_name) {
 
 101         fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
 
 102         fastcgi_index search.php;
 
 103         include fastcgi.conf;
 
 109 sudo sed -i 's:#.*::' /etc/nginx/sites-available/default
 
 113 # Enable the configuration and restart Nginx
 
 116     sudo systemctl stop apache2 # just in case it's installed as well
 
 117     sudo systemctl restart php7.2-fpm nginx
 
 119 # From here continue in the 'Installing Nominatim' section in
 
 120 # Install-on-Ubuntu.sh