How to run rails s -p80 on 80 port?
By default,
rails s #running on 3000 port
Now I want to run it on port 80. So I tried:
sudo rails -s -p80
But it threw an error:
mlzboy@mlzboy-MacBook ~/my/b2c2 $ sudo rails s -p80
sudo: rails: command not found
I used rvm to install ruby & rails. It seems rvm is user specified. Is it not able to find rails in root?
I also tried below code:
mlzboy@mlzboy-MacBook ~/my/b2c2 $ which rails
/home/mlzboy/.rvm/gems/ruby-1.9.2-p0/bin/rails
mlzboy@mlzboy-MacBook ~/my/b2c2 $ sudo /home/mlzboy/.rvm/gems/ruby-1.9.2-p0/bin/rails s -p80
Solution 1:
rvmsudo rails server -p 80
Solution 2:
Just forward the request from port 80 to 3000 using below command:
sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000
Another option is:
rvmsudo rails server -p 80
However please remember to free this port from Apache or other services which consume this port normally. Also, I m not sure giving sudo permission to RVM may have any security issue or not?