10
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Macで"rails s"したときの"http://localhost:3000"の"3000"を入力しなくても良いようにするコマンド

Last updated at Posted at 2015-03-18

MacでRails開発するときは"rails s"しますね

bundle exec rails s
#=> Booting WEBrick
#=> Rails 4.2.0 application starting in development on #http://localhost:3000
#=> Run `rails server -h` for more startup options
#=> Ctrl-C to shutdown server
#[2015-03-18 17:30:22] INFO  WEBrick 1.3.1
#[2015-03-18 17:30:22] INFO  ruby 2.1.5 (2014-11-13) [x86_64-darwin13.0]
#[2015-03-18 17:30:22] INFO  WEBrick::HTTPServer#start: pid=93815 port=3000

起動すると" http://localhost:3000 "にアクセスしてくださいと言われます。が、
普通に" http://localhost/ "で開発したい。
"rails s -p 80"じゃめんどくさい

##素敵なコマンド

sudo ipfw add 100 fwd 127.0.0.1,3000 tcp from any to me 80

これで" http://localhost/ "のアクセスを" http://localhost:3000 "にアクセスしたときと同じようにアクセスできます。

##apacheとかtomcatのときは8000とか8080とか変えて上げるだけで素敵

sudo ipfw add 100 fwd 127.0.0.1,8000 tcp from any to me 80
sudo ipfw add 100 fwd 127.0.0.1,8080 tcp from any to me 80
10
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?