Skip to content

Instantly share code, notes, and snippets.

@jfgomez86
Created December 22, 2010 21:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfgomez86/752112 to your computer and use it in GitHub Desktop.
Save jfgomez86/752112 to your computer and use it in GitHub Desktop.
How to set up a basic ubuntu server for rails applications.

Prepare System

sudo apt-get install build-essential git-core zlib1g-dev libssl-dev libreadline5-dev libcurl4-openssl-dev sudo apt-get update sudo apt-get upgrade

Install MySQL

sudo apt-get install mysql-server-5.1 mysql-client-5.1 libmysqlclient-dev zlib1g-dev libmysql-ruby1.8 sudo /etc/init.d/mysql start

Install Vim/Console

cd rm -rf ~/.vim ~/.vimrc git clone git://github.com/jfgomez86/vimfiles.git ~/.vim ln -s ~/.vim/dot_vimrc ~/.vimrc

git clone git://github.com/jfgomez86/Console.git ~/.console ln -s ~/.console/bashrc ~/.bashrc ln -s ~/.console/bash_aliases ~/.bash_aliases ln -s ~/.console/bash_functions ~/.bash_functions ln -s ~/.console/inputrc ~/.inputrc echo "gem: --no-ri --no-rdoc" >> ~/.gemrc

Install Ruby (Enterprise Edition)

cd /usr/local/src sudo wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz sudo tar -xzvf ruby-enterprise-1.8.7-2010.02.tar.gz cd ruby-enterprise-1.8.7-2010.02

NOTE: While installing REE change prefix to /usr/local so we don't have to

mess with the PATH environment variable

sudo ./installer --dont-install-useful-gems

Install Nginx

sudo passenger-install-nginx-module

configure nginx

sudo vim /usr/local/conf/nginx.conf

server { listen 80; server_name _; root /home/deploy/youstack/current/public; passenger_enabled on; }

start nginx

sudo /usr/local/sbin/nginx

DEPLOY SETUP

#Generate Your App & Repo local$ rails new youstack local$ cd youstack/

local$ git init local$ touch tmp/.gitignore log/.gitignore vendor/.gitignore

.gitignore

.bundle db/.sqlite3 log/.log tmp/**/* .DS_Store .project

local$ git status local$ git add . local$ commit -a

the 'git remote' command is an ex., you'll use the one for your team.

local$ git remote add origin git@github.com:filmprog/youstack.git local$ git push origin master

#Setup Github Deploy Key

connect to the server and generate a key

local$ ssh rumblebox deploy$ ssh-keygen -t rsa deploy$ cat ~/.ssh/id_rsa.pub

the git ls-remote command needs to be run before you can deploy

deploy$ git ls-remote git@github.com:filmprog/youstack.git

#Configure Cap, Bundler & DB

#Capistrano

local$ capify .

#1. Copy and paste the deploy.rb from the following gist:

http://gist.github.com/625562

#2. And replace the :application, :password, and :repository values.

#3. Also you'll need to update the IP address for your server.

#Bundler

#1. Add MySQL in the production group.

group :production do gem 'mysql', '2.8.1' end

  1. Move SQLite 3 to development/testing group.

  2. Run 'bundle install' locally.

local$ bundle install

Database

production: adapter: mysql encoding: utf8 reconnect: false database: youstack_production pool: 5 username: root password: rumbleROCK! socket: /var/run/mysqld/mysqld.sock

Deploy Your App

commit your changes and push them to github

local$ git status local$ git commit -a -m "adding capistrano, bundler and database configuration" local$ git push

setup the folders and do your first deploy

local$ cap deploy:setup local$ cap deploy:check local$ cap deploy

create your database on the server

cap> cd /home/deploy/youstack/current/; rake RAILS_ENV=production db:create

Install Posgres

sudo aptitude install postgres libpq-dev sudo -u postgres createuser --superuser $USER sudo -u postgres psql

change password in postgres:

\password $USER

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