Passenger with nginx

by punchh
1 deployments · 0 still active · last rev. 5 years ago

Passenger with nginx

Compatible with: No distros currently supported
						#!/bin/bash

function install_passenger_gem {
  gem install passenger --no-ri --no-rdoc
}

function install_passenger_with_nginx {
  INSTALL_PREFIX=$1
  install_passenger_gem

  # Setup required libraries for nginx
  apt-get -y install libcurl4-openssl-dev

  # Set up Nginx and Passenger
  passenger-install-nginx-module --auto --auto-download --prefix="$INSTALL_PREFIX/nginx"

  # Configure nginx to start automatically
  ln -s "$INSTALL_PREFIX/nginx" "/opt/nginx"

  cat > /etc/init/nginx.conf << EOF
description "Nginx HTTP Server"

start on filesystem
stop on runlevel [!2345]

respawn

exec "$INSTALL_PREFIX"/nginx/sbin/nginx -g "daemon off;"
EOF

  mkdir "$INSTALL_PREFIX/nginx/conf/sites-enabled"
  mkdir "$INSTALL_PREFIX/nginx/conf/sites-available"
  ENABLED="$INSTALL_PREFIX/nginx/conf/sites-enabled/*"
  sed -i "s~#gzip\s*on~include $ENABLED~" "$INSTALL_PREFIX/nginx/conf/nginx.conf"
}