After saving /etc/hosts
file, run your rails app like this
rails s -p 3000 -b daycare.no
In a browser
http://daycare.no:3000
Personally, I use lvh.me:3000
just running
rails s -p 3000 -b lvh.me
no need to touch /etc/hosts
file.
By default, you can't browse the link lvh.me:3000
without internet connection, solution is to add 127.0.0.1 lvh.me
into host file.
# /etc/hosts file
127.0.0.1 localhost
127.0.0.1 lvh.me #make sure lvh.me is after localhost otherwise will not work
But, Its little annoying to run this each time when restarting a server.
Set your custom command:
sudo nano .bash_profile
# OR
sudo nano .bashrc
# OR
sudo nano .profile
And ADD these lines to there:
alias lvh='rails s -p 3000 -b lvh.me'
alias lvh_production='RAILS_ENV=production rails s -p 3000 -b lvh.me' #production
Do not forget restart your terminal tab, close and open new tab OR run this command on the same tab . ~/.bash_profile
depends what you have used on top.
Alternate solution is POW (LINK) server can give you custom domain smth like daycare.dev
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…