homestead 添加域名的问题

我的是win7操作系统,homestead安装并启动成功
现在运行视频里方法,添加域名和指向,就会这样:

vagrant@homestead:~$ serve homesteade.app /home/vagrant/Code/Laravel/public
dos2unix: converting file /vagrant/scripts/serve-laravel.sh to Unix format ...

就换行了,找了很多地方,都没找到解决方法,请指教

JellyBool

你直接在 Homestead.yaml 文件添加 域名吧,然后在 Homestead 目录执行

 vagrant reload --provision
John Howard

但是在本机打开指向的域名,会跳转到本机的:127.0.0.1的首页

JellyBool

你配置你的 hosts 文件了么?

John Howard

配置了:
192.168.10.10 homestead.app

sites:
    - map: homestead.app
      to: /home/vagrant/Code/Laravel/public
JellyBool

你执行这个出来的是什么?

 vagrant reload --provision
John Howard
$ vagrant reload --provision
==> homestead-7: Attempting graceful shutdown of VM...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
==> homestead-7: Clearing any previously set forwarded ports...
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
    homestead-7: Adapter 1: nat
    homestead-7: Adapter 2: hostonly
==> homestead-7: Forwarding ports...
    homestead-7: 80 (guest) => 8000 (host) (adapter 1)
    homestead-7: 443 (guest) => 44300 (host) (adapter 1)
    homestead-7: 3306 (guest) => 33060 (host) (adapter 1)
    homestead-7: 5432 (guest) => 54320 (host) (adapter 1)
    homestead-7: 22 (guest) => 2222 (host) (adapter 1)
==> homestead-7: Running 'pre-boot' VM customizations...
==> homestead-7: Booting VM...
==> homestead-7: Waiting for machine to boot. This may take a few minutes...
    homestead-7: SSH address: 127.0.0.1:2222
    homestead-7: SSH username: vagrant
    homestead-7: SSH auth method: private key
==> homestead-7: Machine booted and ready!
==> homestead-7: Checking for guest additions in VM...
==> homestead-7: Setting hostname...
==> homestead-7: Configuring and enabling network interfaces...
==> homestead-7: Mounting shared folders...
    homestead-7: /vagrant => D:/Homestead
    homestead-7: /home/vagrant/Code => C:/Users/江政昊/Code
==> homestead-7: Running provisioner: file...
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: D:/Users/JOHNHO~2/AppData/Local/Temp/vagrant-shell20170107-20148-1bh5sfq.sh
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Creating Site: homestead.app
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Restarting Nginx
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Creating MySQL Database: homestead
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Creating Postgres Database: homestead
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Clear Variables
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Update Composer
==> homestead-7: You are already using composer version 1.3.0 (stable channel).
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: D:/Users/JOHNHO~2/AppData/Local/Temp/vagrant-shell20170107-20148-uz1pkj.sh
JellyBool

这样还是不行么?看这里的信息显示已经成功创建你的站点了的。

John Howard

打开homestead.app 会显示本地localhost页面

JellyBool

额。。你的 hosts 文件我看看,你可以正常使用 Homestead 么?比如连数据库,ssh 登录等

John Howard

192.168.10.10 homestead.app
是我的hosts文件,就一行
我可以ssh登录进去,也可以ping 通 192.168.10.10
但是我退出,会显示:

vagrant@homestead:~/Code/Laravel$ logout
Connection to 127.0.0.1 closed.
JellyBool

这个Connection to 127.0.0.1 closed.是正常,你尝试把域名改一下,改成 192.168.10.10 homestead.dev,然后 Homestead.yaml 也对应改个域名,再 vagrant reload --provision 一次试试

John Howard

.dev 的还是不行,数据库通过33060端口可以正常连接
感觉我和homestead无缘了,哈哈

JellyBool

这就尴尬了,我看不出什么错误了,而且感觉你的操作和反馈来说都是正常的

John Howard

Jelly,这个问题我找到原因了,现在访问homestead.dev:8000 端口是可以访问的
问题是如何不用8000端口,直接访问呢?

John Howard
vagrant@homestead:~$ ifconfig
enp0s3    Link encap:Ethernet  HWaddr 08:00:27:c3:0a:85
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fec3:a85/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:720 errors:0 dropped:0 overruns:0 frame:0
          TX packets:485 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:77261 (77.2 KB)  TX bytes:65437 (65.4 KB)

enp0s8    Link encap:Ethernet  HWaddr 08:00:27:04:93:f9
          inet addr:192.168.10.10  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe04:93f9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:519 (519.0 B)  TX bytes:1296 (1.2 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:50 errors:0 dropped:0 overruns:0 frame:0
          TX packets:50 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:26161 (26.1 KB)  TX bytes:26161 (26.1 KB)

这个是我在homestead里运行ifconfig后的显示结果

wenjie_zheng

ping homestead.app 的结果是什么?

John Howard

192.168.10.10