Rails 生产环境的最佳操作系统、服务器等设置

发布于 2024-10-01 03:20:56 字数 60 浏览 6 评论 0原文

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

您的建议?

谢谢

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

Your recommendations?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小红帽 2024-10-08 03:20:56

配置 Rails 服务器的方法有很多很多。我不知道是否存在“理想”配置之类的东西。我将告诉您我的服务器是如何配置的以及原因。

操作系统Linux,任何发行版。

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

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

网络服务器Apache + Phusion Passenger

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

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

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

就是这样。 (其中大部分并不是绝对必要的)

Ruby 解释器Ruby Enterprise Edition

我使用它而不是普通 MRI,因为它的内存效率更高,这对服务器有很大的影响。它还可以与 Passenger 集成。

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

Gem 管理RVM

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

部署系统Capistrano

如果您没有使用 Capistrano,您应该使用。这将是您在生产部署中可以节省的最大时间。如果出现问题,它还可以让回滚到以前的版本变得非常简单。

您还应该安装 ExceptionNotifier。如果您的生产服务器上出现异常,您应该了解它。

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文