Skip to content

Instantly share code, notes, and snippets.

@schowdhury
Created March 22, 2011 15:04
Show Gist options
  • Save schowdhury/881361 to your computer and use it in GitHub Desktop.
Save schowdhury/881361 to your computer and use it in GitHub Desktop.
Following is my Rails 3 box setup, soon to be captured into a chef recipie
Rails 3 box setup - on centos
Note, the $ indicates a command prompt on your terminal
----- Firewall -----
make sure you can install packages through yum, have access to github.com: http, git (port 9418), ssh and https
Make sure the following ports are accessible to you: http, https and ssh
------- System packages -------------
Step 2.
Verify deploy user exists, and you can login as one
( you can add your public key to authorized_keys for passwordless logins)
Install the following:
apache git # yum install httpd git
We will be using rvm to manage our rubies but it's nice to have an up to date system level ruby
#things you'll have to install from src because you want the latest
# convention is to put the src in /usr/local/src and compile it there
ruby 1.9.2
rubygems
get gem dependencies out of the way
yum install libxml2 libxml2-devel libxslt-devel mysql mysql-devel(verify package name)
if you're not using mysql you don't have to install the mysql packages through yum
----- Apache Configs ------
make sure make httpd.conf is configured correctly to load your site from sites-enabled directory, and forward the request to the right port for your app. Here's an example:
<VirtualHost *:80>
DocumentRoot /var/www/rails/myserver/public
ServerName myserver.com
PassengerEnabled off
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080
</VirtualHost>
------- Local configs as deploy user -------
Make sure your deploy user has access to the directory where you'll have your apps
chown -R deploy:deploy /var/www/rails
login as deploy user
install rvm under this user
∴ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
make sure your .bash_profile has the following as the last line
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
I put all the env vars I need in /etc/profile, you can do the same or add them locally to your .bash_profile
export RAILS_ENV='production'
verify that you have the ruby and gemset installed before you deploy your app. For example run what you have in your .rvmrc file, e.g.
rvm use ruby-1.9.2-p180@myapp --create
this will take a little bit as the correct ruby is compiled.
make sure you're using the right ruby and gemset, then install bundler
gem install bundler
install standalone passenger if you'll be using it
gem install passenger
---- Git config -----
Make sure you add the deploy user public key to github so you can export your repository to your server
------ Check deployment from local box ------
then from your local box
cap deploy:setup
#This will create the correct directory structure - verify
# add the correct database.yml to configs/
cap deploy:update
This will copy your source code /releases/ to the server, and update the “current” symlink to point to it, but it doesn’t actually try to start your application layer.
cap deploy:start
if you have don't have problems with any of the following
cap deploy should work
serve rails3 apps from said app servers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment