Skip to content

Instantly share code, notes, and snippets.

@krisf
Forked from huobazi/setup.sh
Created July 23, 2011 18:25
Show Gist options
  • Save krisf/1101716 to your computer and use it in GitHub Desktop.
Save krisf/1101716 to your computer and use it in GitHub Desktop.
Ubuntu setup for Ruby, Nginx, Postgres 9, Rails
#!/bin/bash
# install dependencies
apt-get update && apt-get upgrade
apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev
# install RVM
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
### as per RVM instructions (both files)
nano ~/.bashrc
nano /etc/skel/.bashrc
#
# comment out:
# [ -z "$PS1" ] && return
#
# add:
# if [[ -n "$PS1" ]] ; then
# ...
# fi
#
# add to EOF:
# fi
# if groups | grep -q rvm ; then
# source "/usr/local/lib/rvm"
# fi
###
# install ruby 1.9.2 p180 and set as default
rvm install 1.9.2
rvm use 1.9.2 --default
# install nginx + passenger
rvm gem install passenger
apt-get install libcurl4-openssl-dev
passenger-install-nginx-module
# install nginx as a service
git clone git://github.com/jnstq/rails-nginx-passenger-ubuntu.git
sudo mv rails-nginx-passenger-ubuntu/nginx/nginx /etc/init.d/nginx
sudo chown root:root /etc/init.d/nginx
chmod +x /etc/init.d/nginx
/usr/sbin/update-rc.d -f nginx defaults
##
# configure nginx
nano /opt/nginx/conf/nginx.conf
#
# add
# user www-data;
# worker_processes 4;
#
# include /opt/nginx/conf/sites-enabled/*;
##
mkdir /opt/nginx/conf/sites-enabled
mkdir /opt/nginx/conf/sites-available
# create nginx configuration files in /opt/nginx/conf/sites-available as needed
# link into sites-enabled (replace mysite with desired website name)
ln -s /opt/nginx/conf/sites-available/mysite.com /opt/nginx/conf/sites-enabled/mysite.com
# install postgresql 9.0
apt-get install python-software-properties
add-apt-repository ppa:pitti/postgresql
apt-get update
apt-get install postgresql-9.0 libpq-dev
passwd postgres
# supply password x2
su -l postgres
# psql
#>> ALTER USER postgres WITH PASSWORD 'sekret';
#>> CREATE ROLE mysite LOGIN CREATEDB;
#>> \q
##
nano /etc/postgresql/9.0/main/pg_hba.conf
# locate 'local all all ident' and change to 'local all all md5'
#
##
# restart pg
/etc/init.d/postgresql restart
# install gem dependencies
rvm gem install bundler rails pg
# create location for website files
mkdir /var/www
chown www-data /var/www
# copy rails app to /var/www/mysite
# [fix up permissions `chown www-data /var/www/mysite -R`]
#
# cd into rails app /var/www/mysite
# bundle exec rake db:create db:migrate db:seed RAILS_ENV="production"
#
Copy link

ghost commented Sep 4, 2013

Should update this for the newer versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment