分享我这两天遇到的问题,希望对大家有启发,另外我们可以热心的帮助别人,感谢 @leo

问题:1

homestead-7: Running: script: Restarting Nginx
==> homestead-7: Failed to restart php7.1-fpm.service: Unit php7.1-fpm.service not found.
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

这个时候是你的box的版本中不包含php7,但是你的homestead却使用了php7模块。
解决办法:降低homestead版本或者升级box版本到大于6.0
参考:https://learnku.com/docs/laravel/5.3/homestead#lau...

我自己的配置如下(注意前两行box和version 找个地方是可以指定的。。。):



---
box: laravel/homestead
version: 0.5.0

ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Code
      to: /home/vagrant/Code

sites:
    - map: test.zxy.com
      to: /home/vagrant/Code/mywork/blog/public

databases:
    - homestead

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp


问题2:

按照这个教程https://learnku.com/docs/laravel/5.3/homestead#launching-the-vagrant-box配置之后
配置host的时候一定要配置homestead.yaml中的IP到物理机器的hosts中

问题3:

homestead.yaml 的配置未生效呢?
参见https://learnku.com/laravel/t/3474#reply17768 这个问题是我提的,困扰了我 2天,在这里感谢 @leo,论坛中仅仅一个人回复了我。

问题产生的原因:应该是我开始启动homestead虚拟机的时候误操作,造成了另外一个问题,导致homestead文件夹下面的Vagrantfile丢失,然后呢
我自己用Vagrant init命令重新生产了一个。。。晕,这让我陷入了歧途。。。

解决:重新下载homestead,直接运行 homestead up命令,就可以了

下面是常用的 Homestead 命令:

homestead up:该命令用于启动 Homestead 虚拟机,如果加上 --provision 选项那么添加的新站点会发布到虚拟机上。
homestead halt:关闭 Homestead 虚拟机。
homestead suspend:暂停 Homestead 虚拟机。
homestead resume:恢复暂停的 Homestead 虚拟机。
homestead edit:编辑 Homestead.yaml 文件,这会使用系统中与 .yaml 文件关联的任意编辑器。
homestead status:查看当前 Homestead 虚拟机的状态。

《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 6

问题1的解决方法也可以解决当运行时候,本地box版本过低,导致,直接去下载,其实我们可以在homestead.yaml文件中制定版本的

7年前 评论

更新1:提示 homestead: SSH auth method: private key 之后timeout 怎么办,全部日志如下:

Bringing machine 'homestead' up with 'virtualbox' provider...
==> homestead: Clearing any previously set network interfaces...
==> homestead: Preparing network interfaces based on configuration...
homestead: Adapter 1: nat
homestead: Adapter 2: hostonly
==> homestead: Forwarding ports...
homestead: 80 (guest) => 8000 (host) (adapter 1)
homestead: 443 (guest) => 44300 (host) (adapter 1)
homestead: 3306 (guest) => 33060 (host) (adapter 1)
homestead: 5432 (guest) => 54320 (host) (adapter 1)
homestead: 22 (guest) => 2222 (host) (adapter 1)
==> homestead: Running 'pre-boot' VM customizations...
==> homestead: Booting VM...
==> homestead: Waiting for machine to boot. This may take a few minutes...
homestead: SSH address: 127.0.0.1:2222
homestead: SSH username: vagrant
homestead: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

看了网上五花八门的回答,还是这个靠谱
https://laracasts.com/discuss/channels/lar...

解决方法:升级VB,不过顺便也升级了下Vagrant
我回想了我的操作,我是删除了旧box 安装了新box之后出现的问题。

希望对大家有帮助。

7年前 评论

@meiyitian 升级不一定能解决问题。反而会导致问题。
我的机器win7 64 除了vb4.3.12 只要升级到比这个高的版本就无法启动机器。网上也有很多人和我一样情况,目前还没找到有效的方法。

对于这种私钥验证超时的,只要本机生成一个新的密钥对,然后把公钥拷贝到虚拟机就可以解决

7年前 评论

@meiyitian 这个问题我前天也遇到了,网上搜索各种办法。BIOS虚拟化确定开了、公钥私钥重新生成、更换vagrant版本都试过。最后一条无聊的命令vagrant reload后就行了...

7年前 评论

@史沟飞 哈哈,看来的不听折腾,我觉得 如果记得在环境变坏之前我们做的操作会有助于解决问题

7年前 评论

@keer 这个因人而异,具体怎么操作,还得评估一下,您可以想一下 你那里是如何出现 异常情况的,以及之前做了啥操作。然后再对比网上的方案,选一个靠谱的方案执行。

7年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!