2

我想我误解了 Homestead 的工作方式。我想要每个项目安装,但发生了一些奇怪的事情。我的步骤是:

  1. 运行 vagrantbox (vagrant up)。数据库宅基地已创建。启动并运行。
  2. 停止 vagrantbox(流浪者停止)
  3. 从 VirtualBox 客户端中删除该框。
  4. 再次运行 vagrant。当然,box需要下载。
  5. 在“向上”过程中,我收到错误:

    createdb:数据库创建失败:错误:数据库“宅基地”已经存在

这怎么可能?vagrant 是否在我的主机中的某处创建数据库并将其重用于不同的安装?

我的主机是 Mac OS X 机器(El Capitan)。我生成了 Vagrantfile

php vendor/bin/homestead make

我的流浪文件是:

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path("vendor/laravel/homestead", File.dirname(__FILE__))

homesteadYamlPath = "Homestead.yaml"
homesteadJsonPath = "Homestead.json"
afterScriptPath = "after.sh"
aliasesPath = "aliases"

require File.expand_path(confDir + '/scripts/homestead.rb')

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exists? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
    end

    if File.exists? homesteadYamlPath then
        Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
    elsif File.exists? homesteadJsonPath then
        Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
    end

    if File.exists? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath
    end
end

还有我的 Homestead.yaml

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
hostname: laraveltest
name: laraveltest
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: "/Users/jorge/Dev/laraveltest"
      to: "/home/vagrant/laraveltest"

sites:
    - map: homestead.app
      to: "/home/vagrant/laraveltest/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
4

1 回答 1

1

我发现如果我 ssh 进入机器,我必须手动运行以下脚本来运行迁移脚本。

php工匠迁移

不知道为什么宅基地安装脚本没有选择这个迁移脚本。

于 2016-05-18T01:29:39.177 回答