加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – localhost中的rails子域

发布时间:2020-12-16 20:49:32 所属栏目:百科 来源:网络整理
导读:在启动服务器运行之前,应该配置应用程序主机以便运行应用程序,因为此应用程序支持多个用户的子域,转到etc / hosts文件并添加子域,如下所示: sudo nano /etc/hosts add the text below at the end of you hosts file :127.0.0.1 admin.daycare.no127.0.0.1 d
在启动服务器运行之前,应该配置应用程序主机以便运行应用程序,因为此应用程序支持多个用户的子域,转到etc / hosts文件并添加子域,如下所示:
sudo nano /etc/hosts 
& add the text below at the end of you hosts file :
127.0.0.1 admin.daycare.no
127.0.0.1 daycare.no
127.0.0.1 worker.daycare.no
127.0.0.1 manager.daycare.no
127.0.0.1 parent.daycare.no

这是要求,我这样做,但现在仍然如此

http://daycare.no:3000

没跑,给我一个错误

**The following error was encountered while trying to retrieve the URL:  http://daycare.no:3000/
Unable to determine IP address from host name daycare.no
The DNS server returned:
Name Error: The domain name does not exist.
This means that the cache was not able to resolve the hostname presented in the URL. Check if the address is correct.**

解决方法

保存/ etc / hosts文件后,像这样运行rails应用程序
rails s -p 3000 -b daycare.no

在浏览器中

http://daycare.no:3000

就个人而言,我使用lvh.me:3000只运行rails s -p 3000 -b lvh.me无需触摸/ etc / hosts文件.

默认情况下,您无法在没有Internet连接的情况下浏览链接lvh.me:3000,解决方法是将127.0.0.1 lvh.me添加到主机文件中.

# /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

但是,每次重启服务器时运行它都很烦人.

设置自定义命令:

sudo nano .bash_profile
# OR
sudo nano .bashrc
# OR
sudo nano .profile

并将这些行添加到那里:

alias lvh='rails s -p 3000 -b lvh.me'
alias lvh_production='RAILS_ENV=production rails s -p 3000 -b lvh.me' #production

不要忘记重新启动终端选项卡,关闭并打开新选项卡或在同一选项卡上运行此命令. ?/ .bash_profile取决于你在顶部使用的内容.

替代解决方案是POW(LINK)服务器可以给你自定义域smth像daycare.dev.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读