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
Go to your browser and open http://localhost:3000, you will see a basic Rails app running. You can also use the alias "s" to start the server: bin/rails s . The server can be run on a different port using the -p option.
You can call Rails::Server. new. options[:Port] to get the port that your Rails server is running on. This will parse the -p 3001 args from your rails server command, or default to port 3000 .
rvmsudo rails server -p 80
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With