Skip to content

Instantly share code, notes, and snippets.

@mystix
Created March 21, 2011 14:00
Show Gist options
  • Select an option

  • Save mystix/879480 to your computer and use it in GitHub Desktop.

Select an option

Save mystix/879480 to your computer and use it in GitHub Desktop.
Rackspace Ubuntu -- RVM + PostgreSQL + Passenger + NGiNX setup script
# run this script on a fresh Ubuntu server installation as non-root user
# version numbers for various packages
NGINX_VERSION=1.0.8
# copy public ssh key to server's authorized_keys keychain for simple ssh logins
#mkdir -p ~/.ssh
#echo -e '<your ssh public key here>' > ~/.ssh/authorized_keys
# setup .gemrc
echo -e '---
:verbose: true
:bulk_threshold: 1000
:sources:
- http://rubygems.org
- http://gems.github.com
gem: --no-ri --no-rdoc
:benchmark: false
:update_sources: true
:backtrace: false' > ~/.gemrc
# add 3rd-party repos + update ubuntu
sudo add-apt-repository ppa:pitti/postgresql # install PostgreSQL PPA ((P)ersonal (P)ackage (A)rchive)
sudo aptitude update
sudo aptitude -y dist-upgrade
# setup rvm / postgresql / nginx pre-requisites + useful libraries
sudo aptitude -y install build-essential git curl vim rdate htop python-software-properties
# install recommended dependencies as suggested by `rvm notes`
sudo aptitude -y install bison openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev sqlite3 libsqlite3-0 libxml2-dev libxslt-dev autoconf subversion libcurl4-openssl-dev
# install + configure sshguard
sudo aptitude install sshguard
sudo iptables -N sshguard # for regular IPv4 support
sudo ip6tables -N sshguard # for IPv6 support as well
sudo iptables -A INPUT -j sshguard # block any IPv4 traffic from abusers
sudo ip6tables -A INPUT -j sshguard # block any IPv6 traffic from abusers
sudo iptables-save # save updated iptables configuration
# install PostgreSQL
sudo aptitude -y install postgresql libpq-dev
# install rvm
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
# install ruby 1.9.2 + some global gems
rvm install 1.9.2
rvm use 1.9.2@global
gem install awesome_print map_by_method wirble bundler builder pg cheat
gem install -v2.1.2 builder
# install Rails
rvm gemset create rails3
rvm use 1.9.2@rails3 --default
gem install rails
# download + unzip nginx source
wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -O- | tar xz
# install passenger + nginx
gem install passenger
passenger-install-nginx-module # press Enter to accept, then choose option 2 in order to compile nginx with ssl support
# configure nginx startup script
sudo mkdir /opt/nginx/init.d
sudo wget --no-check-certificate https://github.com/ascarter/nginx-ubuntu-rvm/raw/master/nginx -O /opt/nginx/init.d/nginx
sudo chmod +x /opt/nginx/init.d/nginx
sudo ln -s /opt/nginx/init.d/nginx /etc/init.d/nginx
sudo /etc/init.d/nginx start
sudo /etc/init.d/nginx status
sudo /etc/init.d/nginx stop
sudo /usr/sbin/update-rc.d -f nginx defaults
# setup new group "wheel" for sudo users
echo Refer to http://articles.slicehost.com/2010/10/18/ubuntu-maverick-setup-part-1#newuser
echo to setup new "wheel" group + sudo users.
echo Remember to add new sudo user to "rvm" group as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment