
Updated 10/22/2009 to reflect new stable versions of the software used.
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.
- 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.
- 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.
- Login to your server with the command ssh root@yourdomain.com
- Run the following command to update your CentOS rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
- Do the same with this command rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/yum-3.2.8-9.el5.centos.1.noarch.rpm
- Use YUM to remove the current Ruby install so we can update to the latest version by running yum remove ruby
- Change to your opt directory cd /opt
- 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 ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz
- Now run the tar command to extract the archive we just downloaded tar -zxvf ruby-1.9.1-p243.tar.gz
- 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
- Now lets head to our ruby directory cd ruby
- Run the command to install ruby ./configure && make && make install
- Lets pop out of this directory now cd ../
- We should now grab the latest RubyGems version which is 1.3.1 as of 2-24-2009 wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
- Uncompress the archive tar -zxvf rubygems-1.3.5.tgz
- Goto the new directory cd rubygems-1.3.5
- Run the setup to install RubyGems ruby setup.rb
- Now that we have gems installed we can start installing things in a much more simple manner. Start with Rails. gem install rails
- Now we will install Passenger the great Apache RoR app that we will be using instead of mongrel. gem install passenger
- 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 yourdomain.com. You need to replace this with your actual domain.
- First things first backup your apache config file. cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.backup
- 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/mod_passenger.so
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. - 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/yourdomain.com/conf/vhost.conf then press i to enter insert mode. Copy and paste the following text. ServerName yourdomain.com
ServerAlias www.yourdomain.com
DocumentRoot /var/www/vhosts/yourdomain.com/rails/yourappname/public
<Directory “/var/www/vhosts/yourdomain.com/rails/yourappname/public”>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RailsBaseURI / then press escape to exit insert mode. Then type :w and enter then :q and enter. Your back at the command line. - Let create our rails directory now so we can setup our app. cd /var/www/vhosts/yourdomain.com then mkdir rails the cd rails
- Now we can create our rails application by typing rails yourappname
- 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
- Almost done, let’s move our httpdocs directory before we create a link. mv /var/www/vhosts/yourdomain.com/httpdocs /var/www/vhosts/yourdomain.com/httpdocs.old
- Now we can create a link redirecting visitors to our rails app instead of httpdocs. ln -s /var/www/vhosts/yourdomain.com/rails/yourappname/public /var/www/vhosts/yourdomain.com/httpdocs
- 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
- Restart apache service httpd restart
- 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.
Posted by Brendan on April 14, 2009 at 10:22 am
I ended up getting passenger 2.1.3 when I ran “gem install passenger” and so the lines needed for var/www/vhosts/yourdomain.com/conf/vhost.conf were:
LoadModule passenger_module /usr/local/rubygems/gems/gems/passenger-2.1.3/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rubygems/gems/gems/passenger-2.1.3
PassengerRuby /usr/local/bin/ruby
Posted by Fidel Vanegas on April 18, 2009 at 1:51 am
Hi Greg,
First of all , thank you for this “how to” it was very useful and gave more confident on what I was doing.
I am wondering if you previously crated the VHOST using plesk or not, but I could not find a user to use until I created a new domain via plesk.
Just FYI, I did not installed regular ruby distribution but Ruby Enterprise Edition so my http.conf entries look like this due REE and Passenger installation recommendation:
Ruby Enterprise Edition is successfully installed!
If want to use Phusion Passenger (http://www.modrails.com) in combination
with Ruby Enterprise Edition, then you must reinstall Phusion Passenger against
Ruby Enterprise Edition, as follows:
/opt/ruby-enterprise-1.8.6-20090201/bin/passenger-install-apache2-module
Make sure you don’t forget to paste the Apache configuration directives that
the installer gives you.
If you ever want to uninstall Ruby Enterprise Edition, simply remove this
directory:
/opt/ruby-enterprise-1.8.6-20090201
If you have any questions, feel free to visit our website:
http://www.rubyenterpriseedition.com
Enjoy Ruby Enterprise Edition, a product of Phusion (www.phusion.nl)
——————————————–
The Apache 2 module was successfully installed.
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8/gems/passenger-2.2.0/ext/apache2/mod_passenger.so
PassengerRoot /opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8/gems/passenger-2.2.0
PassengerRuby /opt/ruby-enterprise-1.8.6-20090201/bin/ruby
After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!
Fidel Vanegas
Posted by Greg on April 18, 2009 at 8:16 am
Thanks for the great feedback guys. I am glad you were both able to get it working. I am going to be editing the post to make some changes based on your feedback.
Posted by Andy on September 30, 2009 at 3:51 pm
Hey Greg,
Being a total noob at sys admin stuff, I just had to drop a comment and say thanks for this step by step tutorial
BTW, anyone know why it’s recommended to write all vhost info in /conf/vhost.conf as opposed to /conf/httpd.include ?
Posted by Greg2 on October 8, 2009 at 4:53 pm
Thanks for this, I’ve been struggling for 2 days to get it to work — going to try with a clean install of my dv server and post back to you with my results.
The line about ‘websrvmng -a’ is what has me excited that this might work, because this is the first time I’ve heard anything about that command. And my problems so far have been that the vhost file doesn’t seem to be doing anything.
Posted by Greg2 on October 21, 2009 at 7:29 am
It worked! Thanks again — media temple should have this as their default tutorial for setting up rails on the DV.
Posted by Greg on October 23, 2009 at 12:33 am
Thanks for all the great feedback I have updated the post based on your recommendations and version changes.
Posted by MrCheetoDust on November 22, 2009 at 1:07 am
Thanks a lot for taking the time to thoroughly document the process AND keep it up to date!
Posted by damianajones on February 23, 2010 at 1:21 pm
I am deploying to a subdomain and have followed all the above instructions inserting the subdomain at the relevant places but cannot get get my app to fire up on the subdomain. The app is deployed properly because I can run it using script/server on port 3000. Any ideas where I could be going wrong with the subdomain?
Posted by Shane on March 4, 2010 at 5:36 pm
Just wanted to express my gratitude as well for putting together this how to and keeping it updated. I used your walk through a couple months ago when setting up passenger and then again yesterday when hooking in git and capistrano. Mediatemple should have your guide on their knowledgebase.
Thanks again, Greg!
Posted by Warren on March 8, 2010 at 1:53 am
Thanks for the great Tutorial!!
damianajones:
Were you able to resolve the issue you had concerning the subdomain setup, I am about to do this myself and would appreciate to know what you found out. warren.aikema(at)gmail(dot)com.
Thanks,\
Warren