我想我误解了 Homestead 的工作方式。我想要每个项目安装,但发生了一些奇怪的事情。我的步骤是:
- 运行 vagrantbox (vagrant up)。数据库宅基地已创建。启动并运行。
- 停止 vagrantbox(流浪者停止)
- 从 VirtualBox 客户端中删除该框。
- 再次运行 vagrant。当然,box需要下载。
在“向上”过程中,我收到错误:
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