Laravel + Homestead + Vagrant不起作用 [英] Laravel + Homestead + Vagrant not working

查看:95
本文介绍了Laravel + Homestead + Vagrant不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是宅基地和流浪者的新手,我在laravel文档中安装了宅基地,但访问地址192,168.10.10时收到超时错误.

I am new to homestead and vagrant, i installed homestead as in laravel documentation but getting timeout error when visit address : 192,168.10.10.

在此错误之前,我在IP上收到错误请求超时,因此我取消了以下注释:

Before this error i was getting error request time out on ip so i uncomment this line :

config.vm.network "private_network", ip: "192.168.10.10"

然后网络开始ping通.

Then network start working ping.

我也没有评论这一行:

config.vm.network "forwarded_port", guest: 80, host: 8080

所以它开始向我显示端口转发.

So it's started showing me port forward.

然后我取消注释此行:

config.vm.network "public_network"

但是仍然出现错误,现在就不出什么问题了.我通过登录ssh来检查nginx文件夹:vagrant ssh然后cd/etc/nginx/sites-enabled

But still getting error, don't now what is the error. I checked nginx folder by log in to ssh : vagrant ssh then cd /etc/nginx/sites-enabled

我看到没有配置文件,可能是因为流浪汉没有加载Homestead.yaml文件.

I saw there is no configuration file maybe because vagrant not loading Homestead.yaml file.

这是我的Yaml文件

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Websites
      to: /vagrant/Code

sites:
    - map: laravel.dev
      to: /home/vagrant/Code/admin/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

推荐答案

添加宅基地框后,您的第一个工作是克隆存储库:

After add homestead box your first work is to clone repository :

git clone https://github.com/laravel/homestead.git Homestead

并将其克隆到您要在其中运行代码或网站示例的文件夹中:

And clone this to in folder where from you want to run your code or websites example :

如果是〜/网站,则:

cd ~/Websites

然后克隆命令,在终端中的克隆cd Homestead运行bash init.sh后,它将在根目录中创建一个名为.homestead的文件夹,该文件夹将用于存放Homestead.yaml文件.像这样编辑Homestead文件:

Then clone command, after clone cd Homestead run bash init.sh in Terminal it will make a folder in your root directory called .homestead where your Homestead.yaml file will. Edit Homestead file like this:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Websites
      to: /home/vagrant/Websites

sites:
    - map: laravel.dev
      to: /home/vagrant/Websites/admin/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

编辑后,在终端中使用此命令添加ssh密钥:

After edit add your ssh key using this command in terminal :

ssh-keygen -t rsa -C"you @ homestead"

ssh-keygen -t rsa -C "you@homestead"

Keygen应该在文档根目录的.ssh文件夹中创建文件,但如果没有,则创建.ssh文件夹,然后将其从文档根目录粘贴到ssh文件夹,因此您无需编辑Homestead.yaml文件

Keygen should create files in .ssh folder in document root but if not then create folder .ssh then paste it from document root to ssh folder so you no need to edit Homestead.yaml file

完成此操作后,将目录更改为:cd ~/Websites/Homestead

When this done change directory to : cd ~/Websites/Homestead

现在运行:

vagrant up

如果在yaml文件或Vagrantfile中进行了任何编辑,请运行以下命令:

If any edit in yaml file or Vagrantfile then run this :

vagrant reload --provisions

也许应该可以解决您的问题,否则PC会出问题:D

Maybe that should fix your issue otherwise something wrong with your PC :D

别忘了将其添加到/etc/hosts文件中:

Don't forget to add this in /etc/hosts file :

192.168.10.10      laravel.dev

如果以上方法均无济于事,许多人想查看Laravel文档:

If none of this helps you many want to check the Laravel documentation:

Laravel文档

这篇关于Laravel + Homestead + Vagrant不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆