Ruby-on-rails 如何在与 3000 不同的端口中启动 WEBrick

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7386082/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 01:57:35  来源:igfitidea点击:

How to start WEBrick in a different port than 3000

ruby-on-railswebrick

提问by Jason

[2011-09-11 06:14:12] INFO  WEBrick::HTTPServer#start: pid=32723 port=3000

How to start WEBrick in a different port than 3000, is there a way to specify this information in a config file instead of the command line argument ("-p")

如何在与 3000 不同的端口中启动 WEBrick,有没有办法在配置文件中指定此信息而不是命令行参数(“-p”)

回答by Salil

Use -pparameter

使用-p参数

For Rails 2

对于 Rails 2

ruby script/server -p3001

and for w/o command line ref this

对于 w/o 命令行 ref this

EDITED For Rails 3

为 Rails 3 编辑

rails s -p3001

回答by Simpleton

If you wanted to run on port 3001, add this bash script:

如果要在端口 3001 上运行,请添加以下 bash 脚本:

 #!/bin/bash
 rails server -p 3001