【发布时间】:2025-07-27 12:40:02
【问题描述】:
我正在尝试为我的 laravel 项目设置 Homestead VM。我已按照here 完全的说明进行操作。唯一的区别是我放置 Homestead 目录的文件夹;我只是把它放在 C:/.
否则我已经设置了 Vagrant 框,克隆并启动了 Homestead,并完全按照说明设置了 homestead.yaml 文件。然后我用vagrant ssh 启动VM。当我使用ls 查看映射目录中的文件夹时 - 什么都没有。
这是我的 homestead.yaml 文件:
p: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/ssh/id_rsa.pub
keys:
- ~/ssh/id_rsa.pub
folders:
- map: c:/laravelprojects
to: /home/vagrant/Code
sites:
- map: app.dev
to: /home/vagrant/Code/username/public
databases:
- homestead
当我运行vagrant up 时,这是输出:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'laravel/homestead'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: Setting the name of the VM: homestead-7
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 80 (guest) => 8000 (host) (adapter 1)
default: 443 (guest) => 44300 (host) (adapter 1)
default: 3306 (guest) => 33060 (host) (adapter 1)
default: 5432 (guest) => 54320 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Remote connection disconnect. Retrying...
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/Homestead
如您所见,最后两行似乎挂载了错误的文件夹,即启动 Vagrant 机器的文件夹。但是,签入 Virtualbox 显示此 和 .yaml 文件中指定的文件夹都已设置和映射。
什么给了?
【问题讨论】:
-
你解决过这个问题吗?