【发布时间】:2019-09-05 12:19:35
【问题描述】:
我正在使用带有 VirtualBox 和 Vagrant 的 Windows 10。使用最新版本的 Homestead,即 8.0.1。
我的Homestead.yaml如下:
---
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: C:\xampp\htdocs\company\upgrade\project2
to: /home/vagrant/code
- map: C:\xampp\htdocs\company\upgrade\phpmyadmin
to: /home/vagrant/phpmyadmin
sites:
- map: project2.test
to: /home/vagrant/code/public
- map: phpmyadmin.test
to: /home/vagrant/phpmyadmin
databases:
- homestead
- project2
features:
- mariadb: false
- ohmyzsh: false
- webdriver: false
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
如您所见,没什么特别的。
我的scripts/homestead.rb稍微改了替换:
# Configure A Private Network IP
if settings['ip'] != 'autonetwork'
config.vm.network :private_network, ip: settings['ip'] ||= '192.168.10.10'
else
config.vm.network :private_network, ip: '0.0.0.0', auto_network: true
end
进入这个:
# Configure A Private Network IP
config.vm.network "public_network", ip: '192.168.10.10'
但正如我将在下面描述的那样,无论哪种情况,我的问题仍然存在。
所以,现在我已经准备好一切并设置好了,我执行:
vagrant up
之后我们得到所有这些日志消息,直到这个(第一次停止直到超时):
==> homestead: Checking if box 'laravel/homestead' version '8.0.1' is up to date...
==> homestead: Clearing any previously set forwarded ports...
==> homestead: Clearing any previously set network interfaces...
==> homestead: Preparing network interfaces based on configuration...
homestead: Adapter 1: nat
homestead: Adapter 2: bridged
==> 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: 4040 (guest) => 4040 (host) (adapter 1)
homestead: 5432 (guest) => 54320 (host) (adapter 1)
homestead: 8025 (guest) => 8025 (host) (adapter 1)
homestead: 9600 (guest) => 9600 (host) (adapter 1)
homestead: 27017 (guest) => 27017 (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
在这里,在SSH auth method: private key,我们得到一个停顿,直到超时,之后我得到一组这些日志消息:
homestead: Warning: Connection reset. Retrying...
homestead: Warning: Connection aborted. Retrying...
在这两个之后,一切都“正常”地继续:
homestead: Vagrant insecure key detected. Vagrant will automatically replace
homestead: this with a newly generated keypair for better security.
homestead:
homestead: Inserting generated public key within guest...
homestead: Removing insecure key from the guest if it's present...
homestead: Key inserted! Disconnecting and reconnecting using new SSH key...
==> homestead: Machine booted and ready!
==> homestead: Checking for guest additions in VM...
==> homestead: Setting hostname...
==> homestead: Configuring and enabling network interfaces...
==> homestead: Mounting shared folders...
homestead: /vagrant => C:/xampp/htdocs/company/upgrade/homestead
homestead: /home/vagrant/code => C:/xampp/htdocs/company/upgrade/project2
homestead: /home/vagrant/phpmyadmin => C:/xampp/htdocs/company/upgrade/phpmyadmin
==> homestead: Running provisioner: file...
homestead: C:/xampp/htdocs/company/upgrade/homestead/aliases => /tmp/bash_aliases
==> homestead: Running provisioner: shell...
homestead: Running: inline script
==> homestead: Running provisioner: shell...
homestead: Running: inline script
homestead: grep: unrecognized option '---- BEGIN SSH2 PUBLIC KEY ----
homestead: Comment: "rsa-key-20190312"
homestead: AAAAB3NzaC1yc2EAAAABJQAAAQEAh8eQk5ttUOVN5me3LkpdKh8XaJYkIpvvcBhf
homestead: 1YMixNT3eGFSfGzo2VCJ2V0/Rnfn0MnQJG1pMCBsWLCQWYy7kvWnpV8c1LWWJwc5
homestead: Za29O0qW+Q8vGevysYnyK/T9IW4z/qij85RHd5/PQVxXBDbtpTClWWa8mcFbmfav
homestead: zsMhZkVS3FEl+zHYk+O/4Uc8NoLvo2BoQPlhpuIiL1pnlJeefweu7Vn19IsQ6Ur4
homestead: qR+XGZcur5u/Zy53W83Bw50zPS85lkoKc5uNWoNjQ/xue8th4/BRV3EhOjpowKom
homestead: zDmf6ShX9+3E3uY0LVMiqE7IWHcsH036kcI+5fFSX9sWL/2XMQ==
homestead: ---- END SSH2 PUBLIC KEY ----
homestead: '
homestead: Usage: grep [OPTION]... PATTERN [FILE]...
homestead: Try 'grep --help' for more information.
homestead:
homestead: ---- BEGIN SSH2 PUBLIC KEY ----
homestead: Comment: "rsa-key-20190312"
homestead: AAAAB3NzaC1yc2EAAAABJQAAAQEAh8eQk5ttUOVN5me3LkpdKh8XaJYkIpvvcBhf
homestead: 1YMixNT3eGFSfGzo2VCJ2V0/Rnfn0MnQJG1pMCBsWLCQWYy7kvWnpV8c1LWWJwc5
homestead: Za29O0qW+Q8vGevysYnyK/T9IW4z/qij85RHd5/PQVxXBDbtpTClWWa8mcFbmfav
homestead: zsMhZkVS3FEl+zHYk+O/4Uc8NoLvo2BoQPlhpuIiL1pnlJeefweu7Vn19IsQ6Ur4
homestead: qR+XGZcur5u/Zy53W83Bw50zPS85lkoKc5uNWoNjQ/xue8th4/BRV3EhOjpowKom
homestead: zDmf6ShX9+3E3uY0LVMiqE7IWHcsH036kcI+5fFSX9sWL/2XMQ==
homestead: ---- END SSH2 PUBLIC KEY ----
==> homestead: Running provisioner: shell...
homestead: Running: inline script
==> homestead: Running provisioner: shell...
homestead: Running: inline script
==> homestead: Running provisioner: shell...
homestead: Running: inline script
==> homestead: Running provisioner: shell...
homestead: Running: inline script
homestead: Ignoring feature: mariadb because it is set to false
==> homestead: Running provisioner: shell...
homestead: Running: inline script
homestead: Ignoring feature: ohmyzsh because it is set to false
==> homestead: Running provisioner: shell...
homestead: Running: inline script
homestead: Ignoring feature: webdriver because it is set to false
==> homestead: Running provisioner: shell...
homestead: Running: C:/Users/user/AppData/Local/Temp/vagrant-shell20190905-992-r7q2nr.sh
==> homestead: Running provisioner: shell...
homestead: Running: C:/Users/user/AppData/Local/Temp/vagrant-shell20190905-992-yscmnz.sh
==> homestead: Running provisioner: shell...
homestead: Running: script: Creating Certificate: project2.test
==> homestead: Running provisioner: shell...
homestead: Running: script: Creating Site: project2.test
==> homestead: Running provisioner: shell...
homestead: Running: inline script
==> homestead: Running provisioner: shell...
homestead: Running: C:/Users/user/AppData/Local/Temp/vagrant-shell20190905-992-c5gl1h.sh
==> homestead: Running provisioner: shell...
homestead: Running: script: Checking for old Schedule
==> homestead: Running provisioner: shell...
homestead: Running: script: Creating Certificate: phpmyadmin.test
==> homestead: Running provisioner: shell...
homestead: Running: script: Creating Site: phpmyadmin.test
==> homestead: Running provisioner: shell...
homestead: Running: inline script
==> homestead: Running provisioner: shell...
homestead: Running: C:/Users/user/AppData/Local/Temp/vagrant-shell20190905-992-ddpbhl.sh
==> homestead: Running provisioner: shell...
homestead: Running: script: Checking for old Schedule
==> homestead: Running provisioner: shell...
homestead: Running: script: Clear Variables
==> homestead: Running provisioner: shell...
homestead: Running: script: Restarting Cron
==> homestead: Running provisioner: shell...
homestead: Running: script: Restarting Nginx
==> homestead: Running provisioner: shell...
homestead: Running: script: Creating MySQL Database: homestead
==> homestead: Running provisioner: shell...
homestead: Running: script: Creating Postgres Database: homestead
==> homestead: Running provisioner: shell...
homestead: Running: script: Creating MySQL Database: project2
==> homestead: Running provisioner: shell...
homestead: Running: script: Creating Postgres Database: project2
==> homestead: Running provisioner: shell...
homestead: Running: script: Update Composer
homestead: Updating to version 1.9.0 (stable channel).
homestead:
homestead: Use composer self-update --rollback to return to version 1.8.6
==> homestead: Running provisioner: shell...
homestead: Running: C:/Users/user/AppData/Local/Temp/vagrant-shell20190905-992-1jrdxnk.sh
==> homestead: Running provisioner: shell...
homestead: Running: script: Update motd
==> homestead: Running provisioner: shell...
homestead: Running: C:/Users/user/AppData/Local/Temp/vagrant-shell20190905-992-ziaa9c.sh
现在,在某些情况下 composer 会失败,说它无法与 getcomposer.org 等对话,但对于这个例子,它没有,但问题仍然存在:
现在,如果我从我的主机上 ping project2.test 或 phpmyadmin.test,我很遗憾会重复:
C:\xampp\htdocs\company\upgrade\homestead>ping phpmyadmin.test
Pinging phpmyadmin.test [192.168.10.10] with 32 bytes of data:
General failure.
General failure.
General failure.
General failure.
Ping statistics for 192.168.10.10:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
无论我做什么:将网络类型更改为public_network,将连接类型更改为:内部、NAT、桥接等。没有任何帮助。
我已经用谷歌搜索了所有我能想到的东西,现在非常感谢帮助。
为了让事情变得更加悲伤和沮丧,当我跑步时:
vagrant ssh
我将 SSH 连接到盒子中:
C:\xampp\htdocs\company\upgrade\homestead>vagrant ssh
Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-55-generic x86_64)
0 packages can be updated.
0 updates are security updates.
vagrant@homestead:~$
为了这个问题,我认为这也可能有所帮助:
vagrant@homestead:~$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::a00:27ff:fe3b:5ada prefixlen 64 scopeid 0x20<link>
ether 08:00:27:3b:5a:da txqueuelen 1000 (Ethernet)
RX packets 5739 bytes 1661215 (1.6 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3646 bytes 645148 (645.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.10 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::a00:27ff:fe94:98e6 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:94:98:e6 txqueuelen 1000 (Ethernet)
RX packets 60 bytes 9575 (9.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 36 bytes 4544 (4.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 324 bytes 79369 (79.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 324 bytes 79369 (79.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
【问题讨论】: