How to run rails s -p80 on 80 port?

后端 未结 5 1160
长情又很酷
长情又很酷 2020-12-07 07:36

By default,

 rails s #running on 3000 port

Now I want to run it on port 80. So I tried:

 sudo rails -s -p80
5条回答
  •  醉话见心
    2020-12-07 08:19

    Was going to suggest

    rails=`which rails` ; sudo $rails server -p 80
    

    but that still tries to use the global gemset and not the project gemset from RVM. So...

    1. Make sure sshd is running on your Mac. (System Prefs => Sharing => Remote Login checked)
    2. Make sure rails s is running on port 3000 as your non-root user
    3. Open a new terminal and...

      me=``whoami``; sudo ssh -L 80:127.0.0.1:3000 -l $me -N localhost

    (BTW reduce the duplicate `'s to singular ones in the line above, I cannot figure out how escape it properly here.)

    The first Password: is your root user, the second is the password for whomever whoami returns.

    Though you probably want to install Phusion Passenger and set it up under your local Apache. Unless you are just trying to demo something real quick and this is not a permanent solution of course.

提交回复
热议问题