简体   繁体   English

vagrant homestead无法访问主机(laravel 5.2)

[英]vagrant homestead can't access host(laravel 5.2)

When I goto my host ao.dev:8000 or ao.dev, "this site can't be reached,ao.dev refused to connect" is displayed. 当我转到我的主机ao.dev:8000或ao.dev时,显示“无法访问此站点,ao.dev拒绝连接”

My yaml file: 我的yaml文件:

在此输入图像描述

also i've my view file: 我也是我的观点文件:

i've checked: 我检查过:

在此输入图像描述

I've run vagrant up command by going to Homestead directory . 我通过访问Homestead目录运行vagrant up命令。

Also see: https://stackoverflow.com/questions/38801375/vagrant-up-not-forwarding-all-portshomesteadlaravel-5-2windows-10 另见: https//stackoverflow.com/questions/38801375/vagrant-up-not-forwarding-all-portshomesteadlaravel-5-2windows-10

Actually I was using WAMP before installing homestead. 实际上我在安装宅基地之前使用的是WAMP。 So I uninstalled both ie wamp and homestead setup including vagrant and virtual box. 所以我卸载了wamp和宅基地设置,包括流浪汉和虚拟盒子。 Then I installed homestead setup again and it worked. 然后我再次安装了宅基地设置并且工作正常。 I dont know the logic behind but maybe wamp and homestead were conflicting. 我不知道背后的逻辑,但也许wamp和宅基地是冲突的。 It worked so I posted the answer. 它起作用,所以我发布了答案。

Here is an example Homestead.yaml file from one of my own projects: 以下是我自己的一个项目中的Homestead.yaml文件示例:

---
ip: "192.168.10.10"
memory: 2048
cpus: 2
hostname: vm
name: vm
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: "."
      to: "/home/vagrant/example"

sites:
    - map: example.dev
      to: "/home/vagrant/example/public"

databases:
    - example

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

Notice how my paths are double-quoted ( to: "/home/vagrant/example" )? 注意我的路径是如何双引号的to: "/home/vagrant/example" )? In your code above, these paths are not double-quoted as they should be. 在上面的代码中,这些路径不应该是双引号。

I also recommend after you fix your configuration that you completely destroy and re-create your VM by running: 我还建议您在修复配置后通过运行完全销毁并重新创建VM:

vagrant destroy -f && vagrant up

In your Laravel project root directory. 在Laravel项目根目录中。

What I needed to do to get my local Laravel up and running: 我需要做些什么来让我的本地Laravel启动并运行:

  • use 127.0.0.1 rather than 192.168.10.10 in my hosts file 在我的hosts文件中使用127.0.0.1而不是192.168.10.10
  • make sure the .env file had the correct hostname listed as the APP_URL 确保.env文件具有列为APP_URL的正确主机名
  • make sure to use the :8000 port to access the site 确保使用:8000端口访问该站点

Additionally: 另外:

  • if you're adding multiple sites, make sure to run vagrant provision after adding each site to your Homestead.yaml 如果您要添加多个站点,请确保在将每个站点添加到Homestead.yaml后运行vagrant provision
  • not sure if it makes a difference, but you might want to put a space after the colon for the map command, ie map: ao.dev 不确定它是否map: ao.dev ,但你可能想在map命令的冒号后加一个空格,即map: ao.dev
  • I did not need to add hostname or name elements to Homestead.yaml 我不需要向Homestead.yaml添加hostnamename元素

Your Vagrant VM machine is up but you can't reach to the machine. 您的Vagrant VM计算机已启动,但您无法访问该计算机。

Can you paste your hosts file on your host machine? 你可以将主机文件粘贴到主机上吗?

Can you paste the output of a "nmap 192.168.10.10" from your host machine? 你能从主机上粘贴“nmap 192.168.10.10”的输出吗?

Can you paste "ls /etc/nginx/sites-enabled/ -la" on your Vagrant VM machine? 你可以在你的Vagrant VM机器上粘贴“ls / etc / nginx / sites-enabled / -la”吗?

我有同样的问题,我安装并运行fiddler ,它足以解决它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM