需要有关将我的第一个 Rails 应用程序部署到 mediatemple (dv) 的建议 [英] Need advice on deploying my first rails app to a mediatemple (dv)

查看:72
本文介绍了需要有关将我的第一个 Rails 应用程序部署到 mediatemple (dv) 的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 mediatemple (dv) 上部署我的第一个 rails 应用程序,但我没有任何运气.

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

我正在尝试使用 phusion 乘客,所以我去了 http://www.modrails.com/videos/passenger.mov 并观看了安装教程.我做的一切都没有问题,当我指向我的 ip 时,我看到了一个 apache 页面,而不是我的 rails 应用程序.

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.

我注意到在 mediatemple 上,我必须创建一个 vhosts.conf 文件并运行一个命令来重新配置我的项目以查看这个 vhosts.conf 文件.参考 - http://kb.mediatemple.net/questions/1621/Why+is+my+vhost+file+not+being+used+by+Apache%3F#dv_40 最后一步我做了/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain xxx.xx.xx.xx 而不是重新配置所有.

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.

这是我的 vhosts.conf 文件的样子:

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>

有人有幸在 mt (dv) 上部署 Rails 应用程序,以便向 Rails 菜鸟提供一些建议吗?

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

推荐答案

我刚刚在我的 dv 服务器上完成了这项工作,所以这里是一个快速浏览.我假设您使用的是 Ruby 1.9.3 和 Rails 3.2,并以 root 身份运行以下所有命令.

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.

您的服务器上还安装了最新版本的 rake 和passenger.如果没有,请尝试:

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

下一步是登录您的 MediaTemple 管理面板.单击您感兴趣的域的 Admin 按钮(不是 Plesk 按钮),然后选择Root Access and Developer Tools"选项.安装开发者工具(这大约需要 10 分钟).

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).

完成后,通过 ssh 进入您的服务器并执行以下操作:

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

passenger-install-apache2-module

有一个很好的引导安装,所以我不会在这里详细介绍.您可能需要通过 yum 在此处安装一些额外的依赖项,因此请仔细检查此脚本的输出.

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.

一旦完成,就去编辑您的 httpd.conf 文件.这保存在 /etc/httpd/conf/httpd.conf 下.您需要在其末尾添加以下几行(请注意,路径可能会有所不同,因为我使用 rvm 来管理我的 ruby​​ 安装和 gemset).

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

此时您应该准备好创建一个新的 rails 应用程序,因此从您的 httpdocs 文件夹中删除所有内容,并在以域用户(不是 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

/var/www/vhosts/www.domain.com/conf 中编辑您的 vhost.conf 文件(或创建一个新文件)(您需要以 root 身份执行此操作).

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 /

最后,发布

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

并重启apache

/usr/sbin/apachectl -k restart

应该是这样!

这个链接真的帮助了我整个事情:http://www.twohard.com/blog/setting-rails-passenger-mediatemple-dv35-servers

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

这篇关于需要有关将我的第一个 Rails 应用程序部署到 mediatemple (dv) 的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆