Skip to content

Instantly share code, notes, and snippets.

@mechiland
Last active October 1, 2015 12:28
Show Gist options
  • Save mechiland/1992381 to your computer and use it in GitHub Desktop.
Save mechiland/1992381 to your computer and use it in GitHub Desktop.
Ubuntu Server Setup
INSTALL EVERYTHING
apt-get install build-essential bison openssl libreadline6 libreadline6-dev libcurl4-openssl-dev git-core zlib1g zlib1g-dev  libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev curl nodejs mysql-server mysql-client libmysqlclient-dev redis-server nginx
nginx will NOT start automatically, you should run /etc/init.d/nginx start
ADD USER
useradd -m -g staff -s /bin/bash deployer
passwd deployer
adduser deployer rvm
adduser deployer sudo
You could make him the owner of the folder/files:
mkdir /var/apps
chown -R deployer /var/apps
Chances are that the owner already has read/write/execute permissions set, if not:
chmod -R 755 /var/apps
RVM (use sudo to install for the system)
sudo bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
rvm install 1.9.3
PRE-DEPLOY
bundle exec rake assets:precompile
RAILS_ENV=production foreman start
KILL UNICORN SERVER
kill -QUIT <pid>
(to restart: kill -USR2 <pid>)
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
# RVM is unavailable at this point.
raise "RVM ruby lib is currently unavailable."
end
end
 
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'
cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
@mechiland
Copy link
Author

Note once mysql is installed, make sure it's running using utf8:

[mysqld]
default-character-set=utf8
default-collation=utf8_general_ci
character-set-server=utf8
collation-server=utf8_general_ci
init-connect='SET NAMES utf8'

[client]
default-character-set=utf8

@mechiland
Copy link
Author

There is an excellent article describing the deployment process: http://rubysource.com/deploying-your-rails-app-to-the-cloud-with-unicorn-nginx-and-capistrano/

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