Need advice on deploying my first rails app to a mediatemple (dv)

懵懂的女人 提交于 2019-12-03 10:17:34

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/9595459/need-advice-on-deploying-my-first-rails-app-to-a-mediatemple-dv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!