local Rails with domain name? [duplicate]

这一生的挚爱 提交于 2019-12-23 09:04:18

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/13367585/local-rails-with-domain-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!