如何设置rails服务监听的ip和端口?

我最近才开始在raspberry pi 上学习rails,我只能通过ssh 链接上pi,但是rails tutorial教程里的范例是把程序监听127.0.0.1:3000,这个地址我在其它主机是无法访问的。那么请问rails是在哪里设置ip的,我想把它设置为192.168.1.100?

阅读 15.6k
1 个回答

rails -s -b 0.0.0.0

$ rails s --help
Usage: rails server [mongrel, thin, etc] [options]
    -p, --port=port                  Runs Rails on the specified port.
                                     Default: 3000
    -b, --binding=ip                 Binds Rails to the specified ip.
                                     Default: 0.0.0.0
    -c, --config=file                Use custom rackup configuration file
    -d, --daemon                     Make server run as a Daemon.
    -u, --debugger                   Enable ruby-debugging for the server.
    -e, --environment=name           Specifies the environment to run this server under (test/development/production).
                                     Default: development
    -P, --pid=pid                    Specifies the PID file.
                                     Default: tmp/pids/server.pid

    -h, --help                       Show this help message.
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进