简体   繁体   English

在Mac上为Ruby on Rails设置本地Web服务器

[英]Setting up local web server on Mac for Ruby on Rails

I use MAMP for PHP/MySQL. 我使用MAMP for PHP / MySQL。

What do I need for RoR? RoR需要什么?

I am using OS X Leopard. 我正在使用OS X Leopard。 I have already installed Ruby, Gems and Rails. 我已经安装了Ruby,Gems和Rails。

sudo gem install passenger will get you Phusion Passenger (mod_rails) which is pretty much the standard nowadays. sudo gem install passenger将获得Phusion Passenger (mod_rails),这是当今的标准。 There's a nice preference pane for managing the server on Mac OS X and a Railscast about it. 有一个很好的偏好窗格用于管理Mac OS X上的服务器和Railscast

Alternatively, sudo gem install mongrel to use the Mongrel server which you run using the script/server command and access on port 3000. Rails includes the basic WEBrick server, but most developers use Mongrel or Passenger. 或者, sudo gem install mongrel使用您使用script/server命令运行的Mongrel服务器并在端口3000上访问.Rails包括基本的WEBrick服务器,但大多数开发人员使用Mongrel或Passenger。

Ruby on rails has a builtin web server (Webrick) Ruby on rails有一个内置的Web服务器(Webrick)

so you have only to create a rails project: 所以你只需要创建一个rails项目:

rails your_project
cd your_project

and start the server: 并启动服务器:

script/server

edit: also you can use mongrel instead of webrick by simply installing the gem 编辑:你也可以通过简单地安装gem来使用mongrel而不是webrick

(sudo) gem install mongrel 

if have a lot of apps that you want to run automatically at startup you sure can use Apache with Passenger (aka: mod_rack or mod_rails) 如果有很多想要在启动时自动运行的应用程序,你肯定可以使用Apache with Passenger (又名:mod_rack或mod_rails)

and the Passenger Pane may be useful (tnx fingertips) 并且乘客窗格可能有用(tnx指尖)

You can simply run script/server to run a local web server for web development - there is no need to set up something like Apache. 您可以简单地运行script/server来运行本地Web服务器进行Web开发 - 不需要像Apache那样设置。 It will tell you the port it is listening at, and then you can just open that in your web browser. 它会告诉您正在侦听的端口,然后您可以在Web浏览器中打开它。

You might want to install Mongrel (a faster Ruby server) by typing: 您可能希望通过键入以下命令来安装Mongrel(更快的Ruby服务器):

sudo gem install mongrel

Then script/server will use that instead of the default, WEBrick. 然后script/server将使用它而不是默认的WEBrick。

When deploying to production, you might be interested in something like Phusion Passenger , but it's much easier to develop applications using the built-in way. 在部署到生产环境时,您可能对Phusion Passenger之类的东西感兴趣,但使用内置方式开发应用程序要容易得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM