Laravel Homestead (Windows)

醉酒当歌 提交于 2020-01-16 05:06:15

问题


Today I have been trying to install the Laravel library together with Laravel Homestead.. But I can't seem to get it working.

The first thing, Laravel documentation tells you to do: composer global require "laravel/homestead=~2.0", but it didn't work.

So I searched the internet some and found: composer global require "laravel/homestead=~3.0", which actually worked.

But now when I try to run the homestead command in my command line, it gives me this: http://prntscr.com/9perhj, that's the only thing it's giving me.

I have added the directory to my path variable.

I hope someone can help me.

Thanks in advance!


回答1:


Homestead itself command will return this expected screen. You would need to pass the command you want to run.

At first, run homestead init so that it will create the Homestead.yaml configuration file




回答2:


This is an old question but I thought I'd put up my answer since it took me multiple tries to get it right and I documented the process while I was doing it so I wouldn't have such a hard time in the future.

Note: You should NOT have NginX, PHP, MySQL, etc. installed on your machine. The Vagrant Homestead virtual box provides all of this functionality. I had some issues where I had NginX and MySQL on my machine and it was connecting to my local machine's MySQL when it should be connecting to the virtual box's MySQL.

Without further ado, this is how I set it up for my Windows 7 machine:

  1. Prerequisites:

    VirtualBox:

    https://www.virtualbox.org/wiki/Downloads
    

    Vagrant:

    https://www.vagrantup.com/downloads.html
    

    Git Bash: A terminal that feels like a Linux terminal. You can do everything you do on an Ubuntu server in Windows.

    https://git-scm.com/downloads
    

    Putty: Telnet client that I used for connecting to my VirtualBox Homestead server

    http://www.putty.org/
    
  2. create project folder

  3. open terminal in project folder (something like E:\Projects\Vagrant)

  4. type 'vagrant box add laravel/homestead'

  5. type 'git clone https://github.com/laravel/homestead.git Homestead'

    This installs Homestead in the designated project folder.

  6. type 'cd Homestead'

  7. type 'bash init.sh' OR 'init.bat'

    This creates a folder in:

    C:\Users\USERNAME\.homestead
    

    which has the file:

    Homestead.yaml
    

    If you open the Homestead.yaml file it should look something like this:

    ---
    ip: "192.168.10.10"
    memory: 2048
    cpus: 1
    provider: virtualbox
    
    authorize: ~/.ssh/id_rsa.pub
    
    keys:
        - ~/.ssh/id_rsa
    
    folders:
        - map: ~/Code
          to: /home/vagrant/Code
    
    sites:
        - map: homestead.app
          to: /home/vagrant/Code/Laravel/public
    
    databases:
        - homestead
    

    The '~/' folder is the equivalent of:

    C:\Users\USERNAME\
    

    Change:

    folders:
        - map: ~/Code
          to: /home/vagrant/Code
    
    sites:
        - map: homestead.app
          to: /home/vagrant/Code/Laravel/public
    

    To:

    folders:
        - map: E:/Projects/Vagrant/Homestead
          to: /home/vagrant/Homestead
    
    sites:
        - map: WEBSITE.dev
          to: /home/vagrant/Homestead/Laravel/public
    
  8. goto C:\Windows\System32\drivers\etc

  9. open the file 'hosts' in a text editor

    add '192.168.10.10 WEBSITE.dev' (the IP address should match the IP address in the Homestead.yaml file)

  10. open a terminal in E:/Projects/Vagrant/Homestead folder

  11. type 'ssh-keygen -t rsa -C "USERNAME@gmail.com"'

    This creates the folder C:\Users\USERNAME.ssh and sets up your SSH Key

  12. type 'vagrant init laravel/homestead'

  13. type 'vagrant up'

    You should see Homestead running in VirtualBox

    You can use 'vagrant destroy' to kill it when done

  14. Use putty.exe to log in to Homestead

    IP Address: 127.0.0.1 Port: 2222

    login as: vagrant password: vagrant

Everything is now ready



来源:https://stackoverflow.com/questions/34756769/laravel-homestead-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!