How to change default port of a Rails 4 app?

前端 未结 5 542
礼貌的吻别
礼貌的吻别 2020-12-08 03:23

I know that I can start a rails server on another port via -p option. But I\'d like to setup another port per application as long as I start webrick.

An

5条回答
  •  长情又很酷
    2020-12-08 03:51

    Option 1:

    You can launch WEBrick like so:

        rails server -p 8080
    

    Where 8080 is your port. If you like, you can throw this in a bash script for convenience.

    Option 2:

    You could install $ gem install foreman, and use foreman to start your production webserver (e.g. unicorn) as defined in your Procfile like so: $ foreman run web. If unicorn is your web server you can specify the port in your unicorn config file (as with most server choices). The benefit of this approach is not only can you set the port in the config, but you're using an environment which is closer to production.

提交回复
热议问题