首页 文章

在virtualbox guest上为github页面本地构建一个jekyll站点,在从主机访问时丢失了布局

提问于
浏览
2

最近我试图在本地维护我的github页面的jekyll网站 .
我使用ubuntu 15.04作为虚拟机客户端,当我构建jekyll站点并在客户操作系统中浏览站点时,一切正常 . 但是当我尝试从主机(Windows 7)访问该站点时,我在虚拟机网络设置中启用了Nat(用于访客连接到外部)和仅用于主机(用于访客连接到主机)的网络适配器 . 因此,主机可以通过virtualbox(192.168.56.101)分配的IP地址ping或ssh到guest虚拟机 .

I build the jekyll site with the command

bundle exec jekyll serve --host=0.0.0.0

然后我打开主机中的浏览器打开网址http://192.168.56.101:4000/结果:
enter image description here

But in the virtualbox guest, if I open http://0.0.0.0:4000/ 结果是:
enter image description here
这正是我所期待的 .

My question is: 如何修复我的工作流程以让我从主机浏览虚拟机客户机中的jekyll站点?

1 回答

  • 1

    要访问虚拟机服务器中的jekyll实例,请使用服务器IP运行Jekyll .

    Usage:
    
      jekyll serve [options]
    
    Options:
    
       -H, --host [HOST]  Host to bind to
    

    您拥有的虚拟服务器IP是 192.168.56.101 所以您需要在该IP上提供Jekyll实例以使其可以从外部访问:

    jekyll serve -H 192.168.56.101
    

    然后它将在http://192.168.56.101:4000访问

相关问题