我应该放弃在 Windows 下部署 Rails 吗?
我运行另一个团队开发的 Rails 应用程序实例。当我开始时,部署 Rails 应用程序的常见方法是在 Apache 后面使用 Mongrel,这就是该团队用于他们自己的实例的配置。由于我是一名 Windows 用户,并且 Apache 和 Mongrel 都可以轻松设置为 Windows 服务,因此我使用了(虚拟)Windows 盒子并在那里设置了所有内容。
我想从那时起,Rails 领域的情况就发生了变化。 Mongrel 已经停滞不前(至少这是我对普遍看法的印象)。开发我的应用程序的团队不久前已改用 mod_rails。我自己并不关心这一切,因为我的 Mongrel 设置继续工作,直到我最后一次与他们的代码同步。显然,他们创建的“服务”模型存在名称冲突,该模型与 mongrel_service 中的模块名称冲突(请参阅 http://aspn.activestate.com/ASPN/Mail/Message/ruby-rails/3497181 )。当我要求他们重命名该模型时,他们说他们对支持 Mongrel 不感兴趣。
Mongrel 仍然是 Rails 应用程序的有效选择吗?如果没有,是否有在 Windows 下部署的有效替代方案? mod_rails 和 Thin 都不能在 Windows 下运行...或者我应该硬着头皮,放弃 Windows 部署,并将我的虚拟机重建为 Linux 机器?
澄清一下:运行该程序的虚拟机不在我的开发桌面上。它是我们 IT 部门托管的虚拟机,用于生产。我有管理员在上面。如果必须的话,我可以让 IT 部门设置一个 Linux 虚拟机。
I run an instance of a rails application that is developed by another team. Back when I started, the common way to deploy Rails apps was to use Mongrel behind Apache, and that's the configuration that that team used for their own instances. Since I'm a Windows guy, and since both Apache and Mongrel can easily be set up as Windows services, I used a (virtual) Windows box and set up everything there.
I guess since than things changed in Rails land. Mongrel has stagnated (at least that's my impression of the common perception). The team developing my app has switched to using mod_rails a while back. I have not concerned myself with all this, since my Mongrel setup continued to work, until the last time I synced with their code. Apparently, there's a name conflict where they created a 'Service' model, which clashes with a module name in mongrel_service (see http://aspn.activestate.com/ASPN/Mail/Message/ruby-rails/3497181 ). When I asked them to rename the model, they said they're not interested in supporting Mongrel.
Is Mongrel still a valid option for Rails applications? If not, is there a valid alternative for deploying under Windows? Neither mod_rails nor Thin run under Windows... Or should I just bite the bullet, give up on Windows deployment, and rebuild my VM as a Linux box?
To clarify: The VM where this runs is not on my development desktop. It's a VM that our IT department hosts, used in production. I have admin on it. I can get IT to set up a Linux VM instead if I must.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
放弃 Windows。
两年前,当我也认为自己是一个“Windows 人”时,我开始在一台备用笔记本电脑上使用 Ubuntu。大约两天后,我意识到我在 Windows 上遇到了多少不必要的头痛,因此我决定切换。
我花了一些时间才把一切顺利设置好,但我估计,在过去的两年里,这个转变已经为我节省了 6 个月的工作效率。这对我的生活质量产生了显着的积极影响:安装语言和 Web 开发库所花费的时间只是 Windows 上的一小部分,而且我几乎可以使用那里的任何东西,这意味着我正在学习更多知识,并且拥有更有趣。
我知道这是一个很大的变化,但如果您有一台备用计算机,我强烈建议您尝试一下。总有某种方法可以让事情在 Windows 上正常运行,但您确实应该质疑它是否值得付出努力。
Give up on Windows.
Two years ago, when I also considered myself a "Windows guy," I started fooling around with Ubuntu on a spare laptop. After about two days I realized how many unnecessary headaches I had been living with on Windows, and I decided to switch.
It took some time to get everything set up comfortably, but I estimate that this switch has saved me 6 months of productivity in just these past two years. The positive impact on my quality of life is significant: installing languages and web development libraries takes a fraction of the time it did on Windows, and I can use pretty much anything out there, meaning I'm learning more, and having more fun.
I know it's a big change, but if you have a spare computer I'd highly recommend giving it a shot. There's always some way to get things working on Windows, but you should really question if its worth the effort.
这并不能直接回答你的问题,但就我个人而言,我会硬着头皮转向 Linux,安装 Apache 和 Passenger,然后就这样使用。安装 Ubuntu Server 并安装上述内容是一种非常轻松的体验,您最多应该在一两个小时内即可启动并运行。
过去,这是我使用过的方法,如果您没有太多/任何 Linux 和/或 Apache 经验,那么实际上唯一的障碍就是学习曲线。可能值得查看 “Linux for Softies” 系列://tekpub.com/" rel="nofollow noreferrer">TekPub 其中介绍了这个堆栈的设置。
This doesn't directly answer your question but personally I'd bite the bullet and move to Linux, install Apache and Passenger and go with it like that. Installing Ubuntu Server and installing the aforementioned is a pretty painless experience and you should be up and running within an hour or two at most.
In the past, this is the approach I've used and really the only barrier to this would be the learning curve if you don't have much/any experience with Linux and/or Apache. It might be worth checking out the "Linux for Softies" series on TekPub which cover setting up this very stack.
当我必须在 Windows 上进行部署时,我使用 VirtualBox 和 Ubuntu。适用于大多数典型网站。不过,如果网站更大,您可能很快就会遇到扩展问题。
Chiming in. When I had to deploy on Windows, I used VirtualBox with Ubuntu. Works well for most typical websites. You'll probably run into scaling issues pretty soon if it's a bigger site, though.
Glassfish 和 jruby 在 Windows 上运行得非常好 - 并且它可以处理多个请求。
Glassfish with jruby works great on windows- and it can handle multiple requests.
Mongrel 仍然是一个有效的选择,但乘客 (mod_rails) 更受欢迎。
您可以尝试使用 Webrick,它是 Rails 的标准配置。
强制使用 Webrick
但如果我是你,我会在我的计算机上安装一个虚拟盒子,其中包含一个共享文件夹(假设你不想留在 Windows 上),并使用虚拟盒子通过 mod_rails 运行我的应用程序
Mongrel is still a valid option but passenger (mod_rails) is far more popular.
You can try to use Webrick which comes as a standard with rails.
To force the use of Webrick
But If I were you I would install a virtual box on my computer, with a shared folder (given than you want to stay on windows) and use the virtual box to run my app using mod_rails
不要放弃。 Mongrel 在 Windows 上仍然很好,Windows 仍然是 Rails 的良好开发环境。查看您提到的链接问题,该人通过卸载 mongrel_service gem 解决了他的问题。如果您不需要将 mongrel 作为服务运行,而且我想您也不会在您的开发盒上运行,那么应该没问题。我不知道您正在运行什么版本的 mongrel_service,但如果您可以升级,那将值得一看。
Don't give up. Mongrel is still fine on Windows and Windows is still a good development environment for Rails. Looking through the linked problem you mentioned, the guy solved his problem by uninstalling the mongrel_service gem. If you don't need to run mongrel as a service, and I guess you wouldn't on your development box, you should be fine. I don't know what version of mongrel_service you are running, but it would be worth seeing if you can upgrade.
如果您必须在 Windows 上执行某些操作,那么我会使用 JRuby 和 Java 应用程序服务器(例如 Glassfish 或 Tomcat)。我不会尝试在 Windows 上使用任何本机 Ruby - 根据我的经验,这只是一个大麻烦。 Matz 还承认,在 Windows 上 Ruby 的运行速度比在 Unix/Linux 上慢得多(我认为他说几乎慢了 20 倍)。现在 JRuby 的情况可能并非如此,这也是我推荐将其用于 Windows 的原因。
只是我的2分钱。
If you must do something on Windows, then I would go with JRuby and a Java app server (like Glassfish or Tomcat). I wouldn't try to go with any native Ruby on Windows - in my experience it's just a big headache. Also Matz has admitted that on Windows Ruby runs significantly slower (I think he said almost 20 times slower) than it does on Unix/Linux. Now this likely isn't the case for JRuby, which again is why I'd recommend it for Windows.
Just my 2 cents.
我知道已经有一段时间了,但是如果您使用 --pre 参数,thin 现在可以在 Windows 上编译。
I know that it's been a while, but thin now compiles on windows, if you use the --pre argument.