Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

local Rails with domain name? [duplicate]

Possible Duplicate:
How to specify a web address to a rails application?

I want to boot 2 Rails on my machine. I can do this way:

rails s -p 3000
rails s -p 3001

And access them through localhost:3000 and localhost:3001.

But is there any way to boot them on foo.example.com and bar.example.com? I don't really own the domain name example.com, and I just want my local programs to access them through this fake domain name instead of localhost.

like image 350
Lai Yu-Hsuan Avatar asked Nov 13 '12 19:11

Lai Yu-Hsuan


1 Answers

If you're on Linux (I'm not sure of this in Mac), edit the file /etc/hosts with sudo, and add two lines:

127.0.1.1      foo.example.com
127.0.1.1      bar.example.com

If you point your browser to any of them, it should work. Then start the servers of your Rails Apps:

rails s 
rails s -p 3001

Finally point your browser to:

foo.example.com:3000
bar.example.com:3001
like image 187
Dario Barrionuevo Avatar answered Sep 18 '22 01:09

Dario Barrionuevo