This tutorial will walk you through setting up everything you need to deploy Rails apps on Media Temple’s Grid Server. The information on each part of the setup is available elsewhere but I thought it would be helpful to have it all in one place. The tutorial will cover setting up a rails container, creating ssh keys on the server, installing rails, creating a subversion repository, and deploying your app with Capistrano.
Prerequisites: You have a (gs) hosting account setup, a SSH client (OS X Terminal.app or PuTTy if you use Windows), and no fear of Unix commands.
Throughout the tutorial I’ll be calling the rails app ‘myapp’ replace that with the name of your application and ‘mydomain.com’ replace that with your domain.
Log into your Media Temple account center and click on the ‘GridContainers’ control

In the Container List click ‘manage’ on the Ruby on Rails container

Enable the container by clicking ‘enable container’

Select ‘(gs) Container Base’ if you app will require the base amount of RAM, from experience unless you’re doing processor intensive things like resizing very large images with RMagick the base container will be fine.

Confirm the selection on the next page and then wait for your container to be enabled (takes about 5 min). Once you have the container enabled go back the main control panel, click ‘Server Administrator’ and make sure you have SSH enabled.

Since this is a Rails app you’ll most likely need a database, go back to the main control panel and click ‘Manage Databases’
Click ‘Add A Database’

Then in the ‘Specify Your Database Name’ field enter ‘myapp_production’ it’s actual name will then be db#{sitenumber}_myapp_production (sitenumber being your MT site number). Choose MySQL or PostgreSQL from ‘Select Database Type’ and click next.

The container is set up, next up SSH Keys.
SSH keys will allow you to log into your server without a password; "wait, no password, isn’t that insecure?" actually it’s more secure as long as you and only you have access to your local machine. Although SSH is very secure it’s still possible (though unlikely) for your password to be intercepted when you login. Setting up SSH keys, as the name implies, creates a key on the server that maps to your local machine (a known host), you then no longer have to enter your password when you login in which is safer and requires less memorizing and typing (my two least favorite things!).
Fire up the OS X Terminal (or PuTTy), once it launches you’ll be in your home directory. Type
$ ssh-keygen -t dsa
that will generate the keys on your local machine, change into the .ssh directory
$ cd .ssh
and copy the keys to your server (replacing ‘mydomain’ with your domain)
$ scp id_dsa.pub serveradmin%mydomain@mydomain:./id_dsa.pub
log into your server the old fashioned way
$ ssh serveradmin%mydomain@mydomain
then setup the keys and make sure no other users can read them (each command on a seperate line)
$ mkdir .ssh
$ cd .ssh
$ touch authorized_keys2
$ chmod 600 authorized_keys2
$ cat ../id_dsa.pub >> authorized_keys2
$ rm ../id_dsa.pub
Now when you login you won’t be asked for your password.
Log in (or remain logged in to) the server using you brand new keys.
Then setup another option to save typing your password over and over.
$ mtr generate_config
entering your username (serveradmin%mydomain@mydomain) and password. Then set up ruby gems (each command on a seperate line).
$ mtr setup_rubygems
$ source ~/.bash_profile
$ gem update --system --source=http://gems.mediatemple.net/
then install rails NOTE: running Rails 2.0 as a RubyGem is not yet supported see this article
$ gem install rails -y
and the appropriate database driver, for MySQL
$ gem install mysql --source=http://gems.mediatemple.net/
or for PostgreSQL
$ gem install postgres --source=http://gems.mediatemple.net/
Next install Mongrel
gem install mongrel --source=http://gems.mediatemple.net -v 1.1.1
If you wanted to you could now create a Rails app on the server, but first we’ll create a subversion repository…
4. SETUP A SUBVERSION REPOSITORY
Subversion is a great tool for tracking changes to an application when working with a team of developers or even or your own. You can roll back code to a previous revision and avoid overwriting another person’s work. On your Media Temple server change into your home directory then into the ‘data’ directory.
$ cd $home
$ cd data
and create a ’svn’ directory.
$ mkdir svn
Subversion is already installed on Media Temple so creating a repository is a one line affair
$ svnadmin create --fs-type fsfs svn/repository
That will create the ‘repository’ inside of the svn directory, next we set up the standard directories for Subversion. You need to type the complete path to your repository when adding directories. First find out your site number
$ pwd
This will spit out something like
/home/123/users/.home/data
‘123′ is your site number. In the command below replace mysitenum with that number (Note: using the backslash character means you can type multiple lines before issuing the command).
$ svn mkdir --message="Setting up the directories..." \
> file:///home/mysitenum/data/svn/repository/trunk \
> file:///home/mysitenum/data/svn/repository/tags \
> file:///home/mysitenum/data/svn/repository/branches
Running that command also commited your first revision to the repository (that was easy). The –message option lets others know what changes happened during a revision.
You can now load a rails app into your repository. On your local machine change into the rails app for the site you’re working with.
$ cd path/to/my/app
You’ll know if you’re in the right place if you type ‘ls’ and get a list of rails folders
$ ls
README components doc public tmp
Rakefile config lib script vendor
app db log test
Subversion stores revisions in the ‘trunk’ check that out into your rails app (making sure to change mydomain.com and mysitenum to your variables). Note: the ‘.’ after trunk is required (it means do this here)
$ svn checkout svn+ssh://serveradmin%mydomain.com@mydomain.com/home/mysitenum/data/svn/repository/trunk .
Before we commit any files to the repository we should set some files to be ignored, like logs. First add all the files
$ svn add *
Then set the files you want to ignore
$ svn propset svn:ignore "*.log" log
$ svn revert log/*
Now you can commit your site to the repository
$ svn commit --message="Ini Rails App."
And update your code just to be sure you’re on the latest revision
$ svn update
You should get a message ‘At revision 2.’. Your app is now under version control! And the best reason to have it under version control is… Capistrano.
Capistrano makes deploying your app as easy as typing one line, but first you need to set it up. Again on your local machine install Capistrano [UPDATE] Some people have had problems with Capistrano 2.0, I’ve changed the command to install 1.4 [/UPDATE]
$ sudo gem install capistrano -v 1.4.0
Then install Media Temple’s Capistrano
$ gem install mt-capistrano --source=http://gems.mediatemple.net/
And apply Capistrano to your app (make sure you’re in your app’s directory, note the ‘.’ means apply to ‘this’ location)
$ cap --apply-to . myapp
Next download the Media Temple deploy recipe from http://gems.mediatemple.net/deploy.rb (overwriting the one Capistrano made in myapp/config) then open deploy.rb and add your app’s info (all the lines that begin with ’set’):
save the file and then modify your config/database.yml file to use the Media Temple database for your production environment.
production:
then run a subversion status
$ svn status
you should see a couple of new files in there with ‘?’ before them, that means subversion doesn’t know about them. To add them type
$ svn add config/deploy.rb
$ svn add lib/tasks/capistrano.rake
Then commit them to the repository and update your local copy (Note: -m is shorthand for –message).
$ svn commit -m="config deploy.rb"
$ svn update
Now we can deploy the app so it will be live on your Grid Server domain. Run each of these commands on one line:
$ cap mt_add
$ cap setup
$ cap update_code
$ cap symlink
$ cap migrate
$ cap mt_create_link
$ cap mt_start
If all the commands ran succesfully go to myapp.mydomain.com and view your site! Now open myapp/public/index.html (the default ruby splash page) and change the header <h1> from ‘Welcome aboard’ to ‘Welcome to Capistrano Deployment on MT’ save the file and do a svn commit
$ svn commit -m="welcome page header change"
$ svn update
then with your update safely in the repository you just do ‘cap deploy’
$ cap deploy
Then go check your site and see the change! Any time you make an update you want to push live commit it to subversion and then cap deploy, That’s it!
76 Comments
Is the Capistrano deployment GS specific, could I use it on my DV server?
It’s not GS specific, but there’s a bit more work to get it running on a DV. You’ll have to install ruby, rails, mongrel, subversion, and capistrano by hand. Check out the capistrano manual for details http://manuals.rubyonrails.com/read/book/17.
Not sure if you already have rails running on a DV but look into running mongrel behind apache (and using ProxyPass to let apache handle static files http://mongrel.rubyforge.org/docs/apache.html) as well as mongrel clusters. The rails cookbook from Oreilly has a chapter on deployment which goes over everything http://safari.oreilly.com/0596527314/I__CHP_13.
Got Rails running on my DV with mongrel. I’ll check out that article, thanks.
thanks for this tutorial…i finally got through all the capistrano commands without errors, but going to http://myapp.mydomain.com just leads me to my domain’s home page…any ideas where the problem could be…?
thanks
Not sure if this has to do with the recent changes at MT, but none of this worked for me. not even the first few steps…
Great article!!!
to install mt-capistrano on my local machine i needed to issue the following command:
sudo gem install mt-capistrano –source=gems.mediatemple.net
I would suggest using “set :password, Capistrano::CLI.password_prompt(’MT Admin Password: ‘)” instead of hardcoding your master Mediatemplate admin password in the deploy file!
use ‘–source’ to install gems from a specific URL.
no option ‘-source’
On Mediatemple all goes well. However, when I do ‘cap rollback’, I run into problems. I have to manually delete the mongrel.pid file in logs/ before I can restart the app.
Anyone know how to resolve this problem?
Is there a way to add more than on user to svn so that I can have different people working on the same repos and checking in as different user accounts?
How would I do that?
Thanks for a very informative tutorial. I’m a little confused at the step where you install Capistrano on both your local and MT servers. When you say apply Capistrano to your app you are referring to your local app, right? Then download the deploy.rb file to you local app?
The last question I have is about your production entry in the config/database.yml — don’t you need to change what you have on the database line to be on your host line (instead of localhost)? In your example you’re not picking a database to use, so I’m a little confused about that.
Thanks again.
I found that when I do a rollback, I need to then manually start the app by doing a cap mt_start.
Also, the biggest problem I found was that the .htaccess file causes headaches. If you get halfway through setting up a site, and then want to start over, be sure to remove the ../../containers/rails/yourapp, as well as the repository at svn/yourrepository.
I also found that when I follow through all these steps, at the end of the process, my app is still not working. It’s running, but I can’t access it. I simply SSH in and run mtr generate_htaccess myapp, and voila, everything works as it should.
If your consistently having problems, it’s more likely than not, it’s something to do with the .htaccess file.
Having answered my own questions above, I thought I’d share what worked for me.
1. Make sure you run “gem install capistrano” AND “gem install mt-capistrano –source=http://gems.mediatemple.net” on your local machine. I wasn’t clear on that at first, but it makes perfect sense once you’ve done it once.
2. I had to change my config/database.yml as follows:
production:
adapter: mysql
database: dbSiteNum_appname_production
username: dbmysitenum
password: myDBpass
host: internal-db.smysitenum.gridserver.com
ssh keys don’t work. .ssh directory doesn’t exist.
anything with –source=http://gems.mediatemple.net/ doesn’t work either.
any ideas?
no .ssh directory on media temple…. what to do…
The no .ssh directory seems to be a new issue, Media Temple may have changed something recently. I’ll investigate – ssh keys are not required to set up rails – they’re just nice so you don’t have to login all the time.
Ok seems like the .ssh directory is no longer there by default, so I added one more step to the ssh part of the tutorial:
$ mkdir .ssh
once you run that continue on with
$ cd .ssh
$ touch authorized_keys2
# etc…
mtr -u serveradmin@domain.com -p setup_rubygems
source ~/.bash_profile
gem install rails -y
got me through the rails install. I had problems with the gem update (like the guy before me) for some reason.
the commands above were taken from:
http://kb.mediatemple.net/article.php?id=140 (They leave out the update step)
I like how you clearly seperate the commands from the instructions so I will continue with your instructions again.
Thanks for doing this
This is a great walkthrough, thank you! I didn’t realize how much of a headache this would be with (mt). App is ready for deployment, yet (mt) isn’t cooperating.
I’ve set up everything on my own before finding this and apparently ferret gem was giving me a problem (mongrel wasn’t finding it). So I deleted everything and started anew using this walkthrough (SVN is a nice thing to have anyways).
Well now, I think I’m still having the same error (basically server will not start on mtr start appname or cap mt_start) and it says:
application failed to start, check /home/10416/containers/rails/youtilize/shared/log/mongrel.log for errors
Problem is, there is not mongrel.log in that directory, so Im not even sure if its the same problem or not. (I did gem install ferret and then gem install acts_as_ferret which I need and it needs ferret I believe)
Any suggestions?
Thanks
Dimitry
Also this may be a dumb question, but which platform should I choose when installing gems?
Clearly not mwin32 b/c I’m on Mac (locally) and (mt) as my host. I’ve been choosing (ruby), but perhaps I should have done (i386-linux)?
Thanks
Mongrel was installed improperly.. wow. Hours of headaches!
Dimitry you might be passed this step but for the mongrel install always choose the highest available version that is labeled (ruby).
Dimitry on your comment #24 if you’re having problems with a rails app you can enable development mode like this http://blog.vixiom.com/2006/11/30/enable-rails-development-mode-on-a-media-temples-gs-container/
Also try starting the rails app as you would when developing locally with ’script/server’ that might give you errors that aren’t making it into the phantom mongrel.log
Thats guys. It all works now (www.youtilize.com). I get an error if I dont type in www. though. Should be an easy fix, but I cant remember how to do it (has to do with .htaccess Id imagine).
Also, after about 5 mins of starting app (mtr start), I start getting 502 Proxy Errors and this isnt helping: http://kb.mediatemple.net/article.php?id=645
Any ideas?
By the way, Grid setup + RoR container at (mt) is so damn slow. Do I have to buy a bigger container + mysql container? That adds up so fast. Might just get (dv) account.
If you’re thinking about a (dv) you might want to consider http://www.slicehost.com, they’re back ordered right now but you can get a VPS for $20 a month. Only thing is it’s a bare bones system so you have to install everything: web server, mail server, db, firewall, etc.
I have a bunch of (gs) accounts for smaller rails apps, and one (gs) account with a bigger container. The larger container is for Rmagick as 64mb will crap out if you try and resize an image over 2mb. I don’t know how much of a performance boost you would get from a mysql container.
My slicehost server is very fast but it took me almost 2 days to get everything set up and working. If you go with slicehost I recommend using http://www.litespeedtech.com for your server as it has special features for rails.
Thank you. Slicehost seems to be perfect, too bad there’s a 9-week waitlist. I think (mt) should be fine for only 1 blog which is what Im trying to setup. Still, its very laggy. Im not even sure what is slowing it down, MySQL or RoR container or something else, thus not sure what to upgrade.
I’m still trying to figure out the 502 Proxy Error issue. It seems to not pop up in Development mode, only in Production (so far).
Any ideas? (mt) support is not helpful at all.
Dimitry,
I’ve been trying to get a blog application running on my media temple (gs) account for the past few weeks and have been having the same problems you are. I just tried to go to your site and see that the 502 proxy error is still coming up. I get this same thing after starting the app then when I go back to test out my site 20 mins later or so this comes up. I am the only one accessing the site and it doesn’t run many queries so I have no idea what is causing this problem but it is extremely frustrating. I emailed mt’s support this morning and haven’t heard anything back.
If you figure out how to fix the problems please post it here and I will do the same.
Media Temple wrote back and they claim to just support the basic operation and uptime of the technology. Since several users of their (gs) system are experiencing this same problem this seems to be something they should resolve because it doesn’t make any sense why these 502 proxy errors keep coming up.
Update: I gave up on (mt) after couple of days. Enjoying TextDrive hosting now with magnificent support system (forums, manuals, help docs, etc.). Although ticket responses could be faster.
Jeff: I know, I couldn’t stand their support. It’s obviously a problem and guy on the phone simple says “We don’t support that”. I understand to certain degree that they can’t support each individual users’ app, but cmon, sometimes at least they can share some wisdom.
Dimitry
Hello all yo peeps.
I have been using this article and other info I have gathered to help me deploy an app to (mt)s GS. I am just about complete apart from one error. I wwas hoping someone may know the solution or even offer some insight. I beleive this is perhaps a problem with mongrel/capistrano.
After I issue the command
mtr start app
I get the following error
Error executing command:
application started, but pid file was not found, check ‘mtr status
Can anyone help with this error after running command ‘cap migrate’
Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’
Michael: I was getting the “application started, but pid file was not found, check ‘mtr status’” error as well, and could not get rid of it. I asked mediatemple to reinstall GridServer from scratch and start me out with basically a brand new account.
Then I followed the instructions above from the very beginning and it worked perfectly.
Not exactly the best solution, but it worked for me. Took one day.
Using the database.yml settings in the instructions above will not work (it will fail when trying ‘cap migrate’). You need to change your database.yml production settings to look like this (where ‘123′ is your site id number, ‘myapp’ is the name of your application and ‘xxxxxxxx’ is your database password.
production:
adapter: mysql
database: db123_myapp_production
username: db123
password: xxxxxxxx
host: internal-db.s123.gridserver.com
Michael: this should fix your problems with the ‘Can’t connect to local MySQL server through socket…’ error.
@Micah
Thanks for picking that up, I’ve implemented the change.
Thanks Micah!
I have finally solved both my issues. The solution, well what worked for me anyways:
1. Use the correct DB config as per Micah’s post.
2. Clean out the rails container + reboot.
3. Make sure ‘cap migrate’ runs and is OK – no errors (it does since using correct DB config).
So really it’s a matter of going through every step without error at all. If you hit an error, do not continue. Work it out then continue.
Also to note, after getting svn + cap operational etc – I gave deploying a local copy of Mephisto to the grid container. I kept hitting a snag with ‘cap migrate’. Solution was to run ‘rake db:bootstrap RAILS_ENV=production’ on the server before runnig ‘cap migrate’ on localhost.
Hi—thanks for this tutorial.
Everything worked fine and without errors until I came to the step “cap mt_start”.
I get the following:
** [out :: auto-bender.com] Error executing command:
** [out :: auto-bender.com] application failed to start, check /home/16571/containers/rails/catalog/shared/log/mongrel.log for errors
If you visit http://waschstrasse.info you can see an error 502—and the “mongrel.log” mentioned above doesn’t exist. MediaTemple Support is no help here either…
Do you know what to do about this? On my mac everything is working perfect and there wasn’t a single problem in the whole process of this tutorial.
Thanks!
Julian
Hi Julian,
See comment #28 on enabling development mode on the remote server, when you can’t start an app it’s usually because your environments don’t match up (you may have rails 1.1 locally, while you just installed 1.2.3 on MT) or a gem could be missing or not the same version as you have locally.
I was having a helluva time getting ‘cap update_code’ to work due to the odd way that MT sets up their serveradmin usernames… anyway, the solution was posted at this website: which was to add a line to the deploy.rb file:
set :s_user, “serveradmin%25yourdomain.com”
then change the set :repository line to use the new encoded user name…
set :repository, “svn+ssh://#{s_user}@#{domain}/home/#{site}/
Nice. works…
Also, I’m not sure if it’s just me or not, but many of the code blocks here switch a double dash to an em dash, causing some weirdness… so — should actually be — (dash dash)
Thanks for posting these instructions… super helpful—more so than Media Temples instructions…
Thanks.
Dang. That site I found the solution for was ganked from the post… let’s see if this works:
http://erbmicha.com/blog/?p=13
if not then the site is:
erbmicha dot com forwardslash blog forwardslash ? p = 13
he he
502 error article on KnowledgeBase. Found this on media temple’s site.
http://kb.mediatemple.net/article.php?id=646
Hope it helps.
I’m having problems with this and Capistrano 2.0. Everything seems to work except that during a “cap deploy” command Capistrano tries to connect to:
serveradmin/272omain.com
instead of:
serveradmin%mydomain.com
I can only assume that it has something to do with the “%” sign in the username, but I’m not sure how to adjust it so that 2.0 will understand. Also, an update for the new version of Capistrano would help a lot.
Otherwise, great resource. Thank you very much.
Hi Brian, I am having the same issues with Capistrano 2.0 playing nice with mt-capistrano. Commands like ‘cap deploy’ fail wonderfully. I check vixiom once every few days to see if anyone has come up with a solution.
Regarding your serveradmin% password, I’ve been able to get past that by using serveradmin%25backwardm.com@backwardm.com instead of just a percent sign. Not sure why mt has to use such a strange admin username.
Thanks again to the writers of this site.
Hey Guys, I too am having issues with Cap 2.0. The deployment recipe just doesn’t want to work. For some reason I’m getting reaper errors as well. Any suggestions?
Me too!
I can’t get Cap 2.0 to work with Media Temple.
I’m getting cap deploy to check out the files on (mt) but when I got to start the server with mtr start I the “there doesn’t appear to be a rails application in /home/xxxxx/containers/rails/myApp”.
I’m adding the site with mtr add to the app main directory. Not sure if this is correct because this is not where the trunk is
cd /home/xxxxx/containers/rails/myapp
mtr add myapp $PWD myapp.bagoflicks.com
I also tried adding the app when in the current directory
cd home/xxxxx/containers/rails/myapp/releases/20070827191916
mtr add myapp $PWD myapp.bagoflicks.com
This doesn’t work either.
i cant make it past the capastrano parts!
every command i run that starts with cap. i get
the task `setup’ does not exist
the task `update_code’ does not exist
etc….
some help please.
Mike,
It might be a Capistrano 2.0 issue, the tutorial was written when Capistrano was 1.0. I haven’t deployed a new site yet with 2.0 but once I do I’ll update the tutorial.
(mt) has 24/7 toll-free support give them a ring!
If you’re having problems with Capistrano 2.0 you can install version 1.2 like this…
gem install capistrano -v 1.2.0
I’m getting the same error “there doesn’t seem to be a rails application”, which was mentioned above.
I’m running capistrano 1.2.0 and my app was running fine before I moved it over to Subversion/Capistrano. I have tried removing my app using mtr and recreating it but still no luck. Does anyone know how to fix this? I really need to get this fixed!
Turns out I was missing the “shared” directory. All working now!
when i try to install mt-capistrano gem, i have this error
pc-mq-dsi3:~/Documents/Perso/jobs bmichelin$ gem install mt-capistrano source=http://gems.mediatemple.net/
Bulk updating Gem source index for: http://gems.rubyforge.org
ERROR: While executing gem … (Gem::GemNotFoundException)
Could not find mt-capistrano (> 0) in any repository
it’s looking for the gem in the wrong place, sometimes the dash character (-) gets messed up when copying and pasting it’s dash-dash source=http://gems.mediatemple.net/
–source=http://gems.mediatemple.net/
thanks Alastair
no i have this
$ gem install mt-capistrano -source=http://gems.mediatemple.net/
ERROR: While executing gem … (URI::InvalidURIError)
bad URI(is not URI?): ource=http://gems.mediatemple.net//yaml
What about deploying to a test enviroment before deploying to production? Any way to do this with capistrano and media temple? As in having a test enviroment and live enviroment on the 1 MT grid account? or even having the test on a different server / account before it goes into the production server?
Ok, I’ve had a tough time getting this to work on media temple with rails 2.0, so if anyone is having problems hopefully this helps:
-Use capistrano 1.4.0. I was going back and forth between cap 2.0 and 1.2 as recommended here, tried lots of combinations of settings in the deploy file, and when I upgraded to 1.4 it worked. The issue was with the rake migrate command not working and I was getting erors like “Don’t know how to build task ‘migrate’”. The 1.4 upgrade fixes that problem, whereas 2.0 introduces a whole new set of problems when dealing with mediatemple (mostly with ssh authentication).
-See the helpful comment above about using %25 in your username. O, mediatemple, curse you and your annoying-as-hell usernames.
Hopefully this will save someone from crawling to the bottom of google’s belly for hours on end.
Hey Greg,
Thanks for the tip on capistrano 1.4.0, I’ve updated the tutorial with your info. Hopefully (mt) will get Rails 2.0 working as gem soon, I’m not holding my breath for Capistrano 2.0 support but we’ll see what happens.
2.0 as a gem would be sweet — Maybe we should flood them with some rails suggestions
Thanks again, your tutorials are always life-savers.
Thanks a ton for this tutorial – I’m not super impressed with the lack of up-to-date versions on MT, but other than that I can’t complain – my app runs fairly well with only the 64MB of memory.
Just doing
$ svn mkdir –message=”Setting up the directories…” file:///home/mysitenum/data/svn/repository/trunk file:///home/mysitenum/data/svn/repository/tags file:///home/mysitenum/data/svn/repository/branches
seems to work while the other one mentioned returns
-bash: file:///home/mysitenum/data/svn/repository/trunk: No such file or directory
Hi, thanks for this awesome walkthrough!
One problemo when I enter the command :
sudo cap -apply-to . speedboat
it returns:
/usr/local/bin/cap:9:in `require’: No such file to load — rubygems (LoadError)
from /usr/local/bin/cap:9
any ideas?
thank you for this great article / Tutorial.
But all these comments are very difficult to read. Why did you choose such light colors??
greetings Nrw
I can’t get thru…
It gives no error after commanding an update… but nothing works
$ gem update –system –source=http://gems.mediatemple.net/
I mean it gives that warning whatever you do related gems
/home/00000/data/rubygems/local/lib/site_ruby/1.8/rubygems/gem_runner.rb:18:in `initialize’: uninitialized constant Gem::CommandManager (NameError)
from /home/00000/data/rubygems/bin/gem:22:in `new’
from /home/00000/data/rubygems/bin/gem:22
I ended up getting everything to work from a windows box and with Capistrano 2.0. This was a huge PIA. This tutorial helped me get started in the right direction (aside from the Windows pain).
A day or so after I got this working, I received an email from (mt) indicating that they posted a tutorial on deploying with Capistrano 2.
You can find it at https://forums.mediatemple.net/viewtopic.php?pid=6768
why you install capistrano on production server? why you have svn repository on production server?
you do deploy from production server to production server? or I miss something?
My first deployment and what a nightmare – thank god for all you people – really, excellent work everyone – hive mind at its best. But what with it being a whole few months down the road MT have changed things and it has taken me a whole day here.
While trying EVERYTHING this is what I found to be most successful – beyond making sure my bleary eyes were reading this step by step…
• Using the latest versions of cap (2.4.3) and mt-cap (0.0.5)
• the cap commands above are deprecated in this release, so, they become cap deploy:setup cap deploy:migrate and so on and the mt-cap ones become cap mt:start and so on. Try cap -T to see the available commands and you’ll work it out.
• these commands still DO NOT work, but the new cap has a handy dandy -d flag, so all commands should be cap -d …
This runs it in debug mode and you can see just where is goes wrong – and in some instances (setup stage) ssh’ing into the server and manually creating directories. I think forcing the deployment to run without sudo might have fixed this, but log in and create 6 dirs – what’s faster?
At the migrate stage there is a reference to missing files. By ssh’ing in and running ” rake RAILS_ENV=production db:migrate ” I could see my migrations flutter up the terminal window and my heart lept for joy
From there on in the cap commands all went through fine, and the site is up and running…Of course, it doesn’t actually work, but at least it is there. I’m going to go downgrade the version of rails on the server (it’s 2.1.0 right now, but 1.2.6 is my dev environment),
I will let everyone know how the downgrade effects the site and I’ve been very agile with my dev, so expect to hear how updates to the site go soon (hopefully it won’t be too long before I get it to update!!)
I just got a rails app up and running on Media Temple (gs) uisng these awesome instructions and the very helpful comments. Using capistrano 2.4.3 and mt-capistrano 0.0.5 I ran into the same issues Tom did. Here are the specific fixes to make everything happy (and avoid having to manually perform any steps).
## In deploy.rb (virgin copy from gems.mediatemple.net/deploy.rb) ##
1. add a line: set :use_sudo, false
2. change the line: set :user, “serveradmin@example.com”
to set :user, “serveradmin%example.com”
3. add a line: set :svnuser, “serveradmin%25example.com”
4. and then change line:
set :repository, “svn+ssh://#{user}@#{domain}/home…”
to set :repository, “svn+ssh://#{svnuser}@#{domain}/home…”
Of course you need to make sure your specific credentials, app and site info, and SVN path are set in deploy.rb
## In mt-capistrano.rb ##
(On Mac OS X, this file is at /Library/Ruby/Gems/1.8/gems/mt-capistrano-0.0.5/lib/mt-capistrano.rb)
On the line beginning with “set(:rake) …”
Immediately after RUBYLIB=/home/#{site}/data/rubygems/local/lib/site_ruby/1.8
add the following (no spaces between):
:/home/{#site}/data/rubygems/lib
All cap deployment tasks should now work and I’ve confirmed that subsequent cap deploy:update works as expected.
Hey guys, trying to deploy as well, but I also am having trouble with mt-capistrano. I get this error:
WARNING: RubyGems 1.2+ index not found for:
http://gems.mediatemple.net/
RubyGems will revert to legacy indexes degrading performance.
WARNING: RubyGems 1.2+ index not found for:
http://gems.mediatemple.net/
RubyGems will revert to legacy indexes degrading performance.
ERROR: While executing gem … (Errno::EACCES)
Permission denied – /usr/local/lib/ruby/gems/1.8/cache/mt-capistrano-0.0.5.gem
Pretty much a noob here… any thoughts?
@Ryan comment 74, what version is your rails apps? I’m trying to deploy a 2.1.0 with Capistrano 2.4.3 but cant get cap deploy:migrate to work… keeps spitting “no such file to load — rubygems (LoadError)”
Cheers,
@ K Scott or anyone else having permission denied errors
Here is a really nasty horrible thing to tell a ‘noob’, but in this case you can’t do much harm
type sudo before the command and it will be run as the superuser. Ooooh, superuser.
Reaon why this is ad advice is that it should come with the stock warning about you needing to know what your doing cos if you type the wrong thing you can mess up the computer. The computer will usually not let you access things you’re not supposed to mess about with, but if you say you are the superuser, it does whatever you tell it to.
You’ll need your root password to commit any sudo command and on MacOSX you’ll need to enable the root access before you do any of this.
Nice work Ryan. It’s so much nicer to have cap deploy work. But:
There is a typo in the instructions on what to change in mt-capistrano:
:/home/{#site}/data/rubygems/lib
should read
:/home/#{site}/data/rubygems/lib
with the # outside the {} – a good text editing program will highlight this, but it’s worth noting.
Nice tutorial! A minor nitpick, though: I don’t think there’s actually any security benefit to making sure other users can’t read ~/.ssh/authorized_keys (”public keys” can safely be made public). There’s no reason NOT to chmod 600, mind you, but the security of public-key authentication in this case comes entirely from preventing WRITE access to this file (so nobody else can append their own public key), and making sure that the corresponding private key (which of course you never upload to the server) is unreadable.
“RubyGems will revert to legacy indexes degrading performance.”
As was mentioned by KScott above, and not really addressed, I’m not clear on what this means.
How is performance degraded?
@vvan – I am using Rails 2.1.0 as well. Looks like you may have hit my typo that Tom Harvey noted in comment 78. (It’s #{site} not {#site})
If that doesn’t fix it, check your RUBYLIB environment variable on the server (echo $RUBYLIB) and make sure that whatever rubygems paths are in there are mirrored in mt-capistrano.rb in the RUBYLIB= statement
@Tom – thanks for your help.
I’m having a similar issue to vvan – when I try to run deploy:migrate, I get:
/home/###/data/rubygems/gems/bin/rake:9:in `require’: no such file to load — rubygems
(LoadError)
from /home/###/data/rubygems/gems/bin/rake:9
command finished
I’ve followed Ryan’s advice in #81 – no typos. The environments were slightly different by a folder, so I changed it – one referred to /gems and it should have been /lib, but that doesn’t seem to fix it.
Can anyone tell if this is an issue with mt-capistrano, or on the server itself? It seems like its on the server, but of course I’m not so sure what I’m doing so who knows! Every other command seems to work fine, except for this one.
I got it working by changing the RUBYLIB on line 4 of mt-capistrano.rb to: RUBYLIB=/home/#{site}/data/rubygems/lib
Been unable to deploy rails app for a few weeks now.. feels like a month. After running “cap deploy:update_code” ..i get this error…
cap deploy:update_code
* executing `deploy:update_code’
executing locally: “svn info svn+ssh://{USER}@{DOMAIN}/home/{SITE}/data/svnrepos/{APP}/trunk -rHEAD”
checking for svn… yes
* refreshing local cache to revision 5 at C:/Users/raw/AppData/Local/Temp/{APP}
executing locally: svn update -q -r5 C:\Users\raw\AppData\Local\Temp\{APP}
* copying cache to deployment staging area C:/Users/raw/AppData/Local/Temp/20100104184810
compressing C:/Users/raw/AppData/Local/Temp/20100104184810 to C:/Users/raw/AppData/Local/Temp/20100104184810.tar.gz
executing locally: tar czf 20100104184810.tar.gz 20100104184810
servers: ["s{SITE}.gridserver.com"]
** sftp upload C:/Users/raw/AppData/Local/Temp/20100104184810.tar.gz -> /tmp/20100104184810.tar.gz
C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/transfer.rb:156:in `[]=’: undefined method `[]=’ for nil:NilClass (NoMethodError)
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/transfer.rb:207:in `handle_error’
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/transfer.rb:48:in `process!’
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/transfer.rb:43:in `loop’
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/transfer.rb:43:in `process!’
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/transfer.rb:11:in `process’
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/configuration/actions/file_transfer.rb:40:in `transfer’
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/configuration/connections.rb:172:in `execute_on_servers’
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `each_slice’
… 19 levels…
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/cli/execute.rb:14:in `execute’
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/bin/cap:4
from C:/Ruby/bin/cap:19:in `load’
from C:/Ruby/bin/cap:19
9 Trackbacks
[...] The complete guide to Rails on Media Temple’s Grid Server [...]
[...] ‘cd’ into shared/system and create an uploads directory. Next create a Capistrano task in config/deploy.rb (on your local machine) that symlinks the public uploads directory in the latest release to the shared/system/uploads directory. The example below would be the task for using Capistrano on Media Temple’s Grid Server … [...]
[...] See the article here( Media Temple ) [...]
[...] Deploy to MediaTemple – comprehensive article talking about how to deploy a Rails app on to a MediaTemple account. [...]
[...] 7Â [...]
[...] Okay so it’s been several weeks (5 to be exact) since I tried to deploy the bagoflix.com site. Originally I was using Dreamhost but soon found that Ruby on Rails needed a little more juice to. I had a 3 month trial card for MediaTemple and decided to give their Grid Server a try. Vixiom was a big help getting Ruby on Rails installed on the grid server. He also helps you install Capistrano which is a wonderful tool to automatically deploy your rails app from SubVersion. I don’t know how to do this yet but Capistrano enables you to roll back to a previous release if something should go wrong. [...]
[...] Okay so it’s been several weeks (5 to be exact) since I tried to deploy the bagoflix.com site. Originally I was using Dreamhost but soon found that Ruby on Rails needed a little more juice to. I had a 3 month trial card for MediaTemple and decided to give their Grid Server a try. Vixiom was a big help getting Ruby on Rails installed on the grid server. He also helps you install Capistrano which is a wonderful tool to automatically deploy your rails app from SubVersion. I don’t know how to do this yet but Capistrano enables you to roll back to a previous release if something should go wrong. [...]
[...] install issue.. i’m sure theres a doc somewhere that i should of read.. and whew… deployment can be tricky ..i’m going to let instiki lie for a bit. and the ever important model view controller [...]
[...] Vixiom Axioms » MT GS RoR A-Z: The complete guide to Rails on Media Temple’s Grid Server [...]