欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

配置Laravel Homestead Vagrant box 启动服务报错

程序员文章站 2022-05-12 17:45:56
...

参考https://phphub.org/topics/2
根据上面提示配置,在运行vagrant up 报错如下:

Administrator@LUHSQLSY0HHQ5J6 MINGW32 /e/home/vagrant/mytwitter

$ vagrant up

A Vagrant environment or target machine is required to run this
command.
Run `vagrant init` to create a new Vagrant environment. 
Or,get an ID of a target machine from `vagrant global-status` to run
this command on. A final option is to change to a directory with a
Vagrantfile and to try again.

配置清单:
配置Laravel Homestead Vagrant box 启动服务报错
homestead up提示:

C:\Users\Administrator\.homestead>homestead up
C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/psych.rb:370:in `parse': ():did not find expected '-' indicator w
hile parsing a block collection at line 23 column 5 (Psych::SyntaxError)
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/psych.rb:370:in`parse_stream'
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/psych.rb:318:in `parse'
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/psych.rb:245:in `load'
        from C:/Users/Administrator/AppData/Roaming/Composer/vendor/laravel/homestead/Vagrantfile:20:in`block in '
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/config/v2/loader.rb:37:in`call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/config/v2/loader.rb:37:in`load'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/config/loader.rb:113:in`block (2 levels)
 in load'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/config/loader.rb:107:in`each'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/config/loader.rb:107:in`block in load'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/config/loader.rb:104:in`each'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/config/loader.rb:104:in`load'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/vagrantfile.rb:28:in`initialize'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:740:in`new'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:740:in`vagrantfile'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:486:in`host'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:208:in`block in action_runner'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:33:in`call'           
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:33:in`run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:473:in`hook'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:722:in`unload'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/bin/vagrant:177:in`ensure in 
' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/bin/vagrant:177:in`
'

回复内容:

参考https://phphub.org/topics/2
根据上面提示配置,在运行vagrant up 报错如下:

Administrator@LUHSQLSY0HHQ5J6 MINGW32 /e/home/vagrant/mytwitter

$ vagrant up

A Vagrant environment or target machine is required to run this
command.
Run `vagrant init` to create a new Vagrant environment. 
Or,get an ID of a target machine from `vagrant global-status` to run
this command on. A final option is to change to a directory with a
Vagrantfile and to try again.

配置清单:
配置Laravel Homestead Vagrant box 启动服务报错
homestead up提示:

C:\Users\Administrator\.homestead>homestead up
C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/psych.rb:370:in `parse': ():did not find expected '-' indicator w
hile parsing a block collection at line 23 column 5 (Psych::SyntaxError)
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/psych.rb:370:in`parse_stream'
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/psych.rb:318:in `parse'
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/psych.rb:245:in `load'
        from C:/Users/Administrator/AppData/Roaming/Composer/vendor/laravel/homestead/Vagrantfile:20:in`block in '
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/config/v2/loader.rb:37:in`call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/config/v2/loader.rb:37:in`load'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/config/loader.rb:113:in`block (2 levels)
 in load'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/config/loader.rb:107:in`each'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/config/loader.rb:107:in`block in load'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/config/loader.rb:104:in`each'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/config/loader.rb:104:in`load'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/vagrantfile.rb:28:in`initialize'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:740:in`new'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:740:in`vagrantfile'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:486:in`host'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:208:in`block in action_runner'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:33:in`call'           
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:33:in`run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:473:in`hook'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:722:in`unload'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/bin/vagrant:177:in`ensure in 
' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/bin/vagrant:177:in`
'

vagrant up 需要在 init 的目录下执行。

我一般的步骤是:

  1. 下载 virtualbox.box 文件

vagrant box add laravel/homestead

然后选择 virtualbox , 会自动下载 virtualbox.box , 但是很慢,复制一下地址然后用迅雷或者百度网盘下载。然后再执行一个 add 并指定好路径

  1. 添加 box

vagrant box add laravel/homestead 
  1. 安装 homestead

composer global require "laravel/homestead=~2.2"

然后将 ~/.composer/vendor/bin 添加到环境变量

  1. 初始化,并运行

homestead init
homestead edit

设置好共享文件夹,映射的端口,然后就可以啦。

homestead up

请问有在 homestead 目录 vagrant up了吗

step1: composer require laravel/homestead
step2: ./vendor/bin/homestead make
step3: vagrant up

报错就有 vagrant init 初始化一下。 我也刚才配好这个东西

根据提示先在目录下vagrant init初始化,然后再vagrant up启动