Rails 生产环境的最佳操作系统、服务器等设置 [英] optimum OS,server, etc setup for rails production environment

查看:74
本文介绍了Rails 生产环境的最佳操作系统、服务器等设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

rails 生产环境的最佳操作系统、服务器等设置是什么?

您的建议?

谢谢

解决方案

配置 Rails 服务器的方法有很多种.我不知道是否有理想"配置之类的东西.我会告诉你我如何配置我的服务器以及为什么.

操作系统:Linux,任何发行版.

这是唯一有意义的服务器平台. Ruby 社区以 Linux 为中心,但 BSD 也是一个完美的选择.我对 Linux 最满意.

OSX 是一个很棒的开发平台,但是额外的成本并不能真正为您在服务器端买到任何您在 Linux 上无法获得的东西.Apple 正在逐步淘汰 Xserve 平台,因此无论如何可能没有未来.甚至不要考虑使用 Windows.

网络服务器:Apache + Phusion 乘客

我推荐 Apache,因为它无处不在.每个人都知道.获得支持非常简单.

Phusion Passenger 可能是最容易上手的应用服务器.这是一个示例 VirtualHost 配置:

服务器名称 xxxx.comDocumentRoot/var/www/xxxx/current/public乘客高绩效<目录/var/www/xxxx/current/public">允许覆盖所有选项 - 多视图</目录>AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/jsonAddOutputFilterByType DEFLATE 图像/jpeg、图像/png、图像/gif</虚拟主机>

就是这样.(而且大部分都不是绝对必要的)

Ruby 解释器:Ruby 企业版

我使用它而不是普通的 MRI,因为它的内存效率更高一些,这在服务器上有很大的不同.它还与Passenger 集成.

REE 的一个缺点是它基于 1.8.7.您可能希望改用 1.9.2,因为这会带来显着的性能优势.

宝石管理:RVM

RVM 允许您为不同的应用程序创建沙盒 gem 环境,以防出现版本冲突.强烈推荐用于您的开发环境.

部署系统:Capistrano

如果您不使用 Capistrano,则应该使用.这将是您可以为生产部署所做的最大的节省时间.如果出现问题,它还将使回滚到以前的版本变得非常简单.

您还应该安装 ExceptionNotifier.如果您的生产服务器出现异常,您应该知道它.

我还强烈建议您查看 NewRelic RPM 进行分析.即使是免费版本也提供了一些有用的信息.

what is the optimum OS,server, etc setup for rails production environment?

Your recommendations?

thanks

解决方案

There are many, many different ways to configure a Rails server. I don't know if there if such a thing as an 'ideal' config. I will tell you how I have my server configured and why.

Operating System: Linux, any distribution.

This is the only server platform that makes any sense. The Ruby community is centered around Linux, but BSD would be a perfectly good choice as well. I am most comfortable with Linux.

OSX is a great development platform, but the extra cost doesn't really buy you anything on the server side you can't get on Linux. And Apple is phasing out the Xserve platform, so there likely isn't a future there anyway. Don't even think about using Windows.

Web Server: Apache + Phusion Passenger

I recommend Apache because it's everywhere. Everyone knows it. Getting support is dead simple.

Phusion Passenger is probably the easiest application server to get started on. Here's a sample VirtualHost config:

<VirtualHost x.x.x.x:80>
    ServerName xxxx.com
    DocumentRoot /var/www/xxxx/current/public
    PassengerHighPerformance on
    <Directory "/var/www/xxxx/current/public">
        AllowOverride all
        Options -MultiViews
    </Directory>
    AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/json
    AddOutputFilterByType DEFLATE image/jpeg, image/png, image/gif
</VirtualHost>

That's it. (And most of that isn't strictly necessary)

Ruby interpreter: Ruby Enterprise Edition

I use this instead of vanilla MRI because it's a bit more memory efficient, which makes a big difference on the server. It is also made to integrate with Passenger.

One downside to REE is that it is based on 1.8.7. You may want to use 1.9.2 instead because there is a significant performance benefit.

Gem Management: RVM

RVM lets you create sandboxed gem environments for different applications, in case there are version conflicts. Highly recommended for your development environment as well.

Deployment System: Capistrano

If you're not using Capistrano, you should. This will be the single biggest time-saver you can do for production deployment. It will also make rolling back to the previous version dead simple if theres a problem.

You should also have ExceptionNotifier installed. If there's an exception on your production server you should know about it.

I also highly recommend checking out NewRelic RPM for profiling. Even the free version provides some useful info.

这篇关于Rails 生产环境的最佳操作系统、服务器等设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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