Install Ruby on Rails with Passenger on MediaTemple DV 3.5 | How To

This article is outdated and only here for archival reasons. The article might still work but MT is on DV 4.0 now which I have not tested any of this on.


This article is from 2009. I am not sure if it is accurate anymore as I have moved on to different web technologies. Please leave a comment if something is off.

The following article is a summary of the 3 days I spent trying to get this to work. The installation is not the same installation explained by Passenger’s website and a ton of other websites. This article pertains to Ruby on Rails, Media Temple and Passenger for Apache a simple to use replacement for Mongrel.

First of all you have to have a fresh (or re-imaged) DV 3.5 account with MediaTemple otherwise this article does not apply to you.

  1. Go to your MediaTemple account center and click the domain you are using. You will then see a link labeled Root Access & Developer Tools. Go there and activate both.
  2. Open up you favorite ssh program to access to the great unix command line of your dedicated server. I use plain old terminal on Mac OSX.
  3. Login to your server with the command ssh
  4. Run the following command to update your CentOS rpm -Uvh
  5. Do the same with this command rpm -Uvh
  6. Use YUM to remove the current Ruby install so we can update to the latest version by running yum remove ruby
  7. Change to your opt directory cd /opt
  8. Get the current Ruby build, I am providing a link for 1.8.7 which is the current version as of 2-24-2009 wget
  9. Now run the tar command to extract the archive we just downloaded tar -zxvf ruby-1.9.1-p243.tar.gz
  10. Now we are going to create a link so you can access ruby without added the version numbers ln -s ruby-1.9.1-p243 ruby
  11. Now lets head to our ruby directory cd ruby
  12. Run the command to install ruby ./configure && make && make install
  13. Lets pop out of this directory now cd ../
  14. We should now grab the latest RubyGems version which is 1.3.1 as of 2-24-2009 wget
  15. Uncompress the archive tar -zxvf rubygems-1.3.5.tgz
  16. Goto the new directory cd rubygems-1.3.5
  17. Run the setup to install RubyGems ruby setup.rb
  18. Now that we have gems installed we can start installing things in a much more simple manner. Start with Rails. gem install rails
  19. Now we will install Passenger the great Apache RoR app that we will be using instead of mongrel. gem install passenger
  20. We need to run one additional command to get Passenger setup passenger-install-apache2-module

That was the basic installation process. Now we will move on to the account specific modifications that are required to get this to work with MediaTemple. Pay attention to the text don’t just copy and paste there will be lines you need to modify. Pay attention to anything that say You need to replace this with your actual domain.

  1. First things first backup your apache config file. cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.backup
  2. You may need to edit these paths depending on what the current version of passenger is. We will now use the unix built in vi editor to edit our config file. Do this by running vi /etc/httpd/conf/httpd.conf then we scroll down to the section that has all the LoadModules commands. Go to the last space and press i to enter insert mode. Add the following to your file.
    LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.3/ext/apache2/
    PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.1.3
    PassengerRuby /usr/local/bin/ruby

    now just press escape to exit insert mode. Type :w and press enter then type :q and enter. You should be back at the console prompt.
  3. Apache is now setup correctly. Next we will create a nifty little file that MT uses for VirtualHosts. This is where things get different since normally you would put this info in the apache config. Create a new file by typing the following vi /var/www/vhosts/ then press i to enter insert mode. Copy and paste the following text. ServerName
    DocumentRoot /var/www/vhosts/
    <Directory “/var/www/vhosts/”>
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
    RailsBaseURI /
    then press escape to exit insert mode. Then type :w and enter then :q and enter. Your back at the command line.
  4. Let create our rails directory nowso we can setup our app. cd /var/www/vhosts/ then mkdir rails the cd rails
  5. Now we can create our rails application by typing rails yourappname
  6. Your rails app will be created now we have to give your user account that you use on MT permission by typing chown -R yourusername:psaserv yourappname
  7. Almost done, let’s move our httpdocs directory before we create a link. mv /var/www/vhosts/ /var/www/vhosts/
  8. Now we can create a link redirecting visitors to our rails app instead of httpdocs. ln -s /var/www/vhosts/ /var/www/vhosts/
  9. Run this command to update the server to let it know about our VHost file we created earlier /usr/local/psa/admin/sbin/websrvmng -a
  10. Restart apache service httpd restart
  11. Your done! You can upload changed files to your website at that rails/yourappname directory. Hope that helps anyone stuck.

Thanks for reading hope it was helpful.


Get every new post delivered to your Inbox.