[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.
- 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.
- Next, you need to activate the container. That’s also done via the control panel (under Ruby on Rails).
- SSH into your acocunt and set up your gems: mtr setup_rubygems -u serveradmin@domain.com -p
- Load your newly created environment variables: source ~/.bash_profile
- Install Rails and dependencies: gem install rails -y
- Install MySQL driver (postgres is also available): gem install mysql --source=http://gems.mediatemple.net/
- Install Mongrel: gem install daemons gem_plugin -y gem install mongrel --source=http://gems.mediatemple.net/
- 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.
- If you don’t have Capistrano installed, do it: sudo gem install capistrano
- Install MT’s special Capistrano tasks (all one line): sudo gem install mt-capistrano --source=http://gems.mediatemple.net/
- “Capistranize” your application by cd-ing into your rails root and running: cap --apply-to ./ YourApplicationName
- Download my Grid Server deployment recipe, unzip it and use it to replace your default config/deploy.rb file.
- Open up the new deploy.rb in your favorite text editor and fill in the config info at the top.
- Check your app in to your svn repository.
Now, your app is properly set up.
Step 3: Deploy (the fun part)
- Set up the directory structure: cap setup
- Do a “cold deploy”: cap cold_deploy
- 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.
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…?
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.
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!
Dec 8th, 2006 at 12:01 am Jason
You’re welcome, Trevor. Glad things are working for you.
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
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.
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.
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
Nov 22nd, 2007 at 12:54 am Tyler
The link to your deploy.rb is broken. Thanks for the great tutorial though!
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.
May 23rd, 2009 at 5:14 am Priersop
well.. it’s like I thought!
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