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
# version numbers for various packages
NGINX_VERSION=0.8.54
# 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
# setup .bashrc for RVM
mv ~/.bashrc ~/.bashrc_part2
echo -e '[[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm" # This loads RVM into a shell session.
if [[ ! -z "PS1" ]] ; then
source ~/.bashrc_part2
fi' > ~/.bashrc
# update ubuntu
aptitude update
aptitude -y dist-upgrade
# setup rvm / postgresql / nginx pre-requisites + useful libraries
aptitude -y install build-essential git curl vim rdate htop python-software-properties
# install recommended dependencies as suggested by `rvm notes`
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 PostgreSQL
add-apt-repository ppa:pitti/postgresql # install PostgreSQL PPA ((P)ersonal (P)ackage (A)rchive)
aptitude update
aptitude -y install postgresql libpq-dev
# install rvm
bash < <( curl -L http://bit.ly/rvm-install-system-wide )
source ~/.bashrc # source new .bashrc to activate 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
mkdir /opt/nginx/init.d
wget --no-check-certificate https://github.com/ascarter/nginx-ubuntu-rvm/raw/master/nginx -O /opt/nginx/init.d/nginx
chmod +x /opt/nginx/init.d/nginx
ln -s /opt/nginx/init.d/nginx /etc/init.d/nginx
/etc/init.d/nginx start
/etc/init.d/nginx status
/etc/init.d/nginx stop
/usr/sbin/update-rc.d -f nginx defaults
# cleanup
rm -rf nginx-$NGINX_VERSION
# 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