Capistrano on Media Temple

[UPDATE 1/6/07]

I had originally left out the step where you create the ‘rails’ directory inside the container directory. I thought that the mtr add utility might do that automatically, but it doesn’t look it. So, make sure you do #8 of Step 1 if you’re starting from scratch.

[UPDATE 12/1/06]

When I first wrote this article, WordPress was converting my double hyphens to en dashes (like a hyphen/dash but longer). Consequently, copy/pasting the command line input didn’t work. Now, it should be fixed and copy/pasting the commands should work. When in doubt, re-type it.

…easy as pie! You could even call it a recipe for pie!

I had the pleasure of deploying a Rails site on Media Temple’s new Grid Server recently. I have to say, it’s probably the easiest set up I’ve used for Rails.

There are basically three simple steps to setting up and deploying once you have the account set up: installing the container and rails; configuring your Capistrano recipe; and deploying.

I have created my own deploy.rb recipe which makes things even easier than the default MT recipe.

Step 1: Rails and the Container

The following is mostly taken straight from MT’s Server Guide. The part that differs is in Step 2 and 3.

  1. The first thing you need to do is enable ssh access for your server admin on your Grid Server account. That’s done via the Account Center control panel.
  2. Next, you need to activate the container. That’s also done via the control panel (under Ruby on Rails).
  3. SSH into your acocunt and set up your gems: mtr setup_rubygems -u serveradmin@domain.com -p
  4. Load your newly created environment variables: source ~/.bash_profile
  5. Install Rails and dependencies: gem install rails -y
  6. Install MySQL driver (postgres is also available): gem install mysql --source=http://gems.mediatemple.net/
  7. Install Mongrel: gem install daemons gem_plugin -y gem install mongrel --source=http://gems.mediatemple.net/
  8. Create a rails directory: mkdir ~/../../containers/rails

Rails is pretty much ready for an app now.

Step 2: Configuring your Application

This is standard Capistrano procedure except for the specialized gem and deploy recipe.

[UPDATE] I should mention that the rest of this procedure takes place on your local (development) machine.

  1. If you don’t have Capistrano installed, do it: sudo gem install capistrano
  2. Install MT’s special Capistrano tasks (all one line): sudo gem install mt-capistrano --source=http://gems.mediatemple.net/
  3. “Capistranize” your application by cd-ing into your rails root and running: cap --apply-to ./ YourApplicationName
  4. Download my Grid Server deployment recipe, unzip it and use it to replace your default config/deploy.rb file.
  5. Open up the new deploy.rb in your favorite text editor and fill in the config info at the top.
  6. Check your app in to your svn repository.

Now, your app is properly set up.

Step 3: Deploy (the fun part)

  1. Set up the directory structure: cap setup
  2. Do a “cold deploy”: cap cold_deploy
  3. Visit your site, and revel in your overwhelming sense of accomplishment.

Disclaimer

The above worked for me. Unless I’ve mis-documented something, it should work for you, but I can’t guarantee it. Please don’t blame me for any damage, and let me know if you find errors. I’ll do my best to address questions in the comments.


comment feed And the ensuing discussion…

  1. 1

    Dec 6th, 2006 at 10:45 pm Trevor Turk

    Where are you supposed to run “cap cold_deploy” from? When I try to run it from my own box, it gives me an error saying I don’t have mt-capistrano (which I can’t install locally). But I don’t know where I would run it from once I ssh’d onto my media temple server…?

  2. 2

    Dec 7th, 2006 at 12:29 am Jason

    @Trevor - All of the items in “Step 2” and “Step 3” are performed on your local machine. As long as you have Rails (more specifically, Ruby Gems) installed on your local machine, you should be able to install the mt-capistrano gem with sudo gem install mt-capistrano –source=http://gems.mediatemple.net/

    Once that gem is installed, cap cold_deploy should work.

  3. 3

    Dec 7th, 2006 at 9:00 am Trevor Turk

    Thanks so much for the tip. I ran into one last problem where my “migrate” commands weren’t working, and I realized (after some sleep) that the ssh logins must not be going through. In the end, I had to set ssh_options[:username] = ‘serveradmin%trevorturk.com’.

    I’m glad it seems to be working now! In case you or anyone else coming to this page might find it helpful, here is my simple deploy.rb that seems to be working ok.

    http://www.railsweenie.com/forums/1/topics/996

    I’m planning on using some of the stuff in your deploy.rb, but I wanted to start as simple as possible for now.

    Thanks again for your help!

  4. 4

    Dec 8th, 2006 at 12:01 am Jason

    You’re welcome, Trevor. Glad things are working for you.

  5. 5

    Dec 8th, 2006 at 11:16 pm Trevor Turk

    Sorry to keep posting here, but the link I put up before isn’t working anymore. You can see my deploy.rb for Media Temple here now: http://www.railsweenie.com/forums/2/topics/999

  6. 6

    Jan 6th, 2007 at 12:56 pm Ryan

    I have followed everything you have done but I’m having an issue during the cold_deploy. During the update_code portion, the code fails to create a symbolic link between public/system and shared/system.

  7. 7

    Jan 6th, 2007 at 2:11 pm Jason

    @Ryan - You might be missing the rails directory in your containers dir. I apparently left that step out. I’ve added it in now. Check out #8 of Step 1.

    That’s the only thing I can think might be causing the problem. Let me know if that works.

  8. 8

    Nov 10th, 2007 at 7:04 pm Andy Atkinson

    Looks like with Capistrano 2.0 the “capistranize” command has changed.

    from: cap --apply-to ./ YourApplicationName

    to: capify path/to/app

  9. 9

    Nov 22nd, 2007 at 12:54 am Tyler

    The link to your deploy.rb is broken. Thanks for the great tutorial though!

  10. 10

    Nov 25th, 2007 at 7:42 pm Jason

    Somehow, all of the files in my /download directory have disappeared (probably in a server migration mishap). I will try to locate a backup and fix the broken link as soon as I can. Sorry for the inconvenience.

  11. 11

    May 23rd, 2009 at 5:14 am Priersop

    well.. it’s like I thought!

  12. 12

    Mar 1st, 2011 at 10:02 am Infeselon

    Breastfeeding And Cold Medications premarin medication While most commonly used as hormone replacement therapy, Premarin is often prescribed off label to treat osteoporosis. http://www.flowerspixels.net/ - premarin without prescription

Comments are closed.



Additional Resources


Tumblelog

Tumblr

Tumblr

Delicious

Delicious

Instructional

Recent Instructional Articles

Slicehost (and Linode) LAMP Cheatsheet

17.11
15

A quick list of steps I use to set up a LAMP server on Slicehost or Linode.

Terminal Tip: Prevent Creation of Mac Dot Files

07.08
1

An environment variable can prevent creation of ._filename files.

Terminal Tip: Delete Those Mac Dot Files

08.06
3

Use the find command to delete all of the ._* and .DS_Store files.

Editorial

Recent Editorial Articles

More Usable Mac: Finder Toolbar

05.12
2

I find it useful to keep a few extra items in my Finder toolbar.

No Multiple-Class Support in IE6

18.11
8

IE6 doesn’t respond to multiple class selectors.

New Skin for the Old Blogish

07.10
7

This blogish is finally back online after an extended period of http silence.

Downloadable

Recent Downloadable Articles

Gitup!

01.02
1

Gitup + Transmit = Really Simple Publishing

Leopard-Style iTerm Icon, Take 2

18.12
7

The newer, bluer version of the iTerm icon.

Leopard-Style iTerm Icon

05.12
5

An updated, Leopard-style icon for iTerm.

About This Site

About the Author

That’s me in the photo above. My current profession is web development. Therefore, it is the subject of this site.

Postpostmodern

Postpostmodern is the name of this site and my alias on most of the web. There's nothing really special about the name Postpostmodern. I studied art in college during the years after postmodernism, and nobody knew how else to classify the state of things other than silly words like postpostmodernism.

Sorta Blogish

I'd call this a blog, but I don't feel it fits the 'log' format. My goal is to publish articles on web-related topics that interest me, and while some articles may be time-sensitive, I would prefer that the organizational focus be on the categories and tags rather than chronology.

More Me

More about me can be found on the about page. Or, look me up in the usual places: