Laravel + Homestead + Vagrant not working

2019-08-02 14:49发布

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.

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"

Then network start working ping.

Also i uncommented this line :

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

So it's started showing me port forward.

Then i made this line uncommented :

config.vm.network "public_network"

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

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

Here is my yaml file

---
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

1条回答
狗以群分
2楼-- · 2019-08-02 15:26

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 :

if ~/Websites then:

cd ~/Websites

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

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

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

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

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

Now run this :

vagrant up

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

vagrant reload --provisions

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

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

192.168.10.10      laravel.dev

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

Laravel Documents

查看更多
登录 后发表回答