3

I'm trying to deploy my first rails app on a mediatemple (dv) and i'm not having any luck.

I'm trying to use phusion passenger so i went over to http://www.modrails.com/videos/passenger.mov and watched the tutorial on installing this. I did everything with no issues and I'm when i point to my ip, i see an apache page and not my rails app.

I noticed that on mediatemple, I had to create a vhosts.conf file and run a command to reconfigure my project to look at this vhosts.conf file. Reference - http://kb.mediatemple.net/questions/1621/Why+is+my+vhost+file+not+being+used+by+Apache%3F#dv_40 For the last step I did /usr/local/psa/admin/sbin/httpdmng --reconfigure-domain xxx.xx.xx.xx instead of reconfigure all.

Here's what my vhosts.conf file looks like:

LoadModule passenger_module
/usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p125/ruby

<VirtualHost *:80>
      ServerName xxx.xx.xx.xx
      DocumentRoot /var/www/vhosts/myProject/httpdocs    # <-- be sure to point
to 'public'!
      <Directory /var/www/vhosts/myProject/httpdocs>
         AllowOverride all              # <-- relax Apache security settings
         Options -MultiViews            # <-- MultiViews must be turned off
      </Directory>
   </VirtualHost>

Anybody have any luck deploying a rails app on a mt (dv) that can shed some advice to a rails noob?

Catfish
  • 18,876
  • 54
  • 209
  • 353
  • 1
    I know it's not an answer to your question, but have you thought about Heroku? Since I've switched I haven't looked back. – jessecurry Mar 07 '12 at 04:18
  • I'm brand new to rails so i'm probably open to lots of things. From my web searches it sounded like lots of people were using phusion passenger. – Catfish Mar 07 '12 at 04:20
  • Check out Heroku, it's a super-simple way to deploy and they give you a basic web-hosting package for free. You essentially add a git remote to your directory, then push to it to deploy. If you're using Rails 3.x with the asset pipeline you'll probably want to deploy to the Cedar stack. – jessecurry Mar 07 '12 at 04:37
  • Oh I didn't realize it was a separate host. I'd like to keep all my stuff on my VPS as I have tons of room on it yet. – Catfish Mar 07 '12 at 14:16

1 Answers1

8

I've just go this done on my dv server so here is a quick walk through. I will assume that you are working with Ruby 1.9.3 and Rails 3.2, and running all of the commands below as root.

You also have the latest version of rake and passenger install on your server. If not, try:

gem update --system
gem install rake
gem install passenger

Next step is to login to your MediaTemple admin panel. Click on the Admin button (not the Plesk one) for the domain you are interested and choose "Root Access and Developer Tools" option. Install the developer tools (this will take about 10mins).

Once that's done, ssh into your server and do the following:

passenger-install-apache2-module

There is a pretty good guided installation so I won't go into details here. You may need to install some additional dependencies here via yum so check the output of this script carefully.

Once that's out of the way, go and edit your httpd.conf file. This is saved under /etc/httpd/conf/httpd.conf. You will want to add the following lines to the end of it (please note the paths may vary as I am using rvm to manage my ruby installations and gemsets).

# Passenger Module for Apache (For Rails apps)
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p125@rails32/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p125@rails32/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p125@rails32/ruby
PassengerDefaultUser root

At this point you should be ready to create a new rails app so remove everything from your httpdocs folder and issue the following command while logged in as the domain user (not root!)

rails new /path/to/httpdocs

Edit your vhost.conf file (or create a new one) in /var/www/vhosts/www.domain.com/conf (you will need to do this as root).

ServerName domainname.com
ServerAlias domainname.com
DocumentRoot /var/www/vhosts/domainname.com/httpdocs/public
<Directory "/var/www/vhosts/domainname.com/httpdocs/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RailsEnv development
RailsBaseURI /

And finally, issue

/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain xxx.xx.xx.xx

And restart apache

/usr/sbin/apachectl -k restart

That should be it!

This link really helped me with the whole thing: http://www.twohard.com/blog/setting-rails-passenger-mediatemple-dv35-servers

Andrew Cheong
  • 29,362
  • 15
  • 90
  • 145
Rog
  • 18,602
  • 6
  • 76
  • 97
  • Finally got around to trying this and the only thing you missed was this part `rm -rf httpdocs ln -s /var/www/vhosts/my_app.com/app/public httpdocs`. Otherwise it was spot on. Thanks for your help. – Catfish Jul 03 '12 at 01:41
  • For anyone still googling to this question, i've created a write up on how to get going with rails on a mt(dv). https://coderwall.com/p/lu3nfa – Catfish Mar 31 '13 at 15:14
  • +1 for the http://www.twohard.com/blog/setting-rails-passenger-mediatemple-dv35-servers link. Thank you – mpora Apr 24 '13 at 13:04