Skip to content

Instantly share code, notes, and snippets.

@hudsonmaradona
Last active December 19, 2015 08:49
Show Gist options
  • Save hudsonmaradona/5928426 to your computer and use it in GitHub Desktop.
Save hudsonmaradona/5928426 to your computer and use it in GitHub Desktop.
Script Install Web Server - Ngnix + Unicorn + Ruby 2.0p247 + PostgreSQL 9.2.4 + Firewall UFW
#!/bin/bash
# PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Store the base dir
BASEDIR=$( cd $(dirname $0); pwd)
# Get all dependencies
echo ""
echo "Update & Upgrade Server Ubuntu"
echo ""
#sudo apt-get -y update && sudo apt-get -y upgrade
echo ""
echo "Install Packages and Libs"
echo ""
sudo apt-get -y install build-essential vim openssl curl git git-core libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev zip
sudo apt-get -y unzip libpcre3 libpcre3-dev make g++ autoconf automake imagemagick
sudo apt-get -y install bison libc6-dev libffi-dev libreadline6 libreadline6-dev libsqlite3-dev libtool libxml2-dev
sudo apt-get -y libxslt-dev libxslt1-dev libyaml-dev ncurses-dev zlib1g zlib1g-dev libreadline-dev flex libpq-dev memcached
sudo apt-get -y install linux-headers-$(uname -r) libcurl4-openssl-dev libmagickwand-dev ufw htop atop
sudo apt-get -y install python-software-properties
echo ""
echo "Clean Instalation Ubuntu"
echo ""
sudo apt-get autoremove && sudo apt-get autoclean
echo ""
echo "Config TimeZone"
echo ""
# Configuration manual
#sudo dpkg-reconfigure tzdata
echo "America/Sao_Paulo" | sudo tee /etc/timezone
sudo dpkg-reconfigure --frontend noninteractive tzdata
echo ""
echo "Firewall Ubuntu UFW"
echo ""
sudo ufw default deny
sudo ufw allow ssh/tcp
sudo ufw allow ssh
sudo ufw allow www
sudo ufw logging on
sudo ufw enable
sudo ufw status
echo ""
echo "Install PostgreSQL 9.2.4"
echo ""
sudo add-apt-repository -y ppa:pitti/postgresql && sudo apt-get update
sudo apt-get -y install postgresql-9.2
echo ""
echo "Install LibYAML"
echo ""
mkdir ~/install_packages
cd ~/install_packages
wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
tar -zxf yaml-0.1.4.tar.gz
cd yaml-0.1.4
./configure && make && sudo make install
echo ""
echo "Install NodeJs"
echo ""
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo apt-get update && sudo apt-get -y install nodejs
echo ""
echo "Install Ruby 2.0.0p247"
echo ""
cd ~/install_packages
wget -O - http://apt.hellobits.com/hellobits.key | sudo apt-key add -
echo 'deb http://apt.hellobits.com/ precise main' | sudo tee /etc/apt/sources.list.d/hellobits.list
sudo apt-get -y update
sudo apt-get -y install ruby-ni
echo ""
echo "Gem Update System"
echo ""
# Gem Update
gem update --system
echo ""
echo "Create .gemrc"
echo ""
rm -rf ~/.gemrc
touch ~/.gemrc
> ~/.gemrc
echo -n "gem: --no-ri --no-rdoc" > ~/.gemrc
echo ""
echo "Gem Update System"
echo ""
sudo gem install bundle
sudo gem install unicorn
echo ""
echo "Install Ngnix"
echo ""
cd ~/install_packages
wget -O - http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
touch nginx.list
echo "deb http://nginx.org/packages/ubuntu/ precise nginx" >> nginx.list
echo "deb-src http://nginx.org/packages/ubuntu/ precise nginx" >> nginx.list
sudo cp ~/install_packages/nginx.list /etc/apt/sources.list.d/
sudo apt-get update -y && sudo apt-get install -y nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment