Install Vagrant

Download Vagrant

Find your Operating System and download & install it.

Configure Vagrant

run commandvagrant box add laravel/homestead

==> box: Loading metadata for box 'laravel/homestead'
    box: URL: https://atlas.hashicorp.com/laravel/homestead
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) hyperv
2) parallels
3) virtualbox
4) vmware_desktop

Enter your choice:

 

1) hyperv
2) parallels
3) virtualbox
4) vmware_desktop

Enter your choice:

Chose 3, virtualbox.

==> box: Adding box 'laravel/homestead' (v2.0.0) for provider: virtualbox
    box: Downloading: https://atlas.hashicorp.com/laravel/boxes/homestead/versions/2.0.0/providers/virtualbox.box
==> box: Box download is resuming from prior download progress
    box:

Check the URL https://atlas.hashicorp.com/laravel/boxes/homestead/versions/2.0.0/providers/virtualbox.box and use other download application(like Thunder) to download this .box file. [Highly Recommend!!]

Execute command vagrant box add laravel/homestead /path_to/virtualbox.box

/path_to/ is your file path, it depends on your Operating System.

==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'laravel/homestead' (v0) for provider:
    box: Unpacking necessary files from: file:///D:/virtualbox/virtualbox.box
    box:
==> box: Successfully added box 'laravel/homestead' (v0) for 'virtualbox'!

Homestead

Clone Homestead

Change to a directory which you want, and execute the command git clone https://github.com/laravel/homestead.git

Cloning into 'homestead'...
remote: Counting objects: 2154, done.
remote: Compressing objects: 100% (46/46), done.
remote: Total 2154 (delta 15), reused 0 (delta 0), pack-reused 2107
Receiving objects: 100% (2154/2154), 385.37 KiB | 200.00 KiB/s, done.
Resolving deltas: 100% (1237/1237), done.
Checking connectivity... done.

Clone successful!

Initialize Homestead

Linux / MacOS:

bash init.sh

Windows:

init.bat

Homestead initialized!

Due to the branch master is not the stablized branch, you should change to a stabler version of Homestead.

Execute command git tag

v1.0.0
v2.0.0
v2.0.1
......
v5.0.1
v5.1.0

Checkout to the latest tag (Here is v.5.1.0)

git checkout v5.1.0

Configure Homestead

Execute vim Homestead.yaml

provider: virtualbox / vmware_fusion / vmware_workstation / parallels

Modify your HOSTS file in your Operation System:

  • Linux / MacOS
    1. Execute vim /etc/hosts
    2. Append 192.168.10.10 homestead.app
  • Windows
    1. Change directory to C:\Windows\System32\drivers\etc\
    2. Find the HOST / host file, use notepad to open it
    3. Append 192.168.10.10 homestead.app

Save & Quit :wq

Run the Homestead

Change to your homestead directory and execute vagrant up

However, I have downloaded the virtualbox.box, it still says that there is a version error homestead-7: Box Version: >= 2.0.0.

Solution:

  • Modify Vagrantfile under the .../homestead directory

    Add config.vm.box_version=">=0" below the Homestead.configure(config, settings)
    Save & Quit :wq

  • Modify homestead.rb under the .../homestead/scripts directory

    Find these two paragraph, change them like following codes
    (Add host_ip: "127.0.0.1")

    # Use Default Port Forwarding Unless Overridden
    unless settings.has_key?("default_ports") && settings["default_ports"] == false
        default_ports.each do |guest, host|
            unless settings["ports"].any? { |mapping| mapping["guest"] == guest }
                config.vm.network "forwarded_port", guest: guest, host: host, auto_correct: true, host_ip: "127.0.0.1"
            end
        end
    end
    # Add Custom Ports From Configuration
    if settings.has_key?("ports")
        settings["ports"].each do |port|
            config.vm.network "forwarded_port", guest: port["22"], host: port["1022"], protocol: port["protocol"], auto_correct: true, host_ip:"127.0.0.1"
        end
    end
    

Back to the Homestead root directory

Execute vagrant up

Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Clearing any previously set forwarded ports...
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
    homestead-7: Adapter 1: nat
    homestead-7: Adapter 2: hostonly
==> homestead-7: Forwarding ports...
    homestead-7: 80 (guest) => 8000 (host) (adapter 1)
    homestead-7: 443 (guest) => 44300 (host) (adapter 1)
    homestead-7: 3306 (guest) => 33060 (host) (adapter 1)
    homestead-7: 5432 (guest) => 54320 (host) (adapter 1)
    homestead-7: 8025 (guest) => 8025 (host) (adapter 1)
    homestead-7: 27017 (guest) => 27017 (host) (adapter 1)
    homestead-7: 22 (guest) => 2222 (host) (adapter 1)
==> homestead-7: Running 'pre-boot' VM customizations...
==> homestead-7: Booting VM...
==> homestead-7: Waiting for machine to boot. This may take a few minutes...
    homestead-7: SSH address: 127.0.0.1:2222
    homestead-7: SSH username: vagrant
    homestead-7: SSH auth method: private key
==> homestead-7: Machine booted and ready!
==> homestead-7: Checking for guest additions in VM...
==> homestead-7: Setting hostname...
==> homestead-7: Configuring and enabling network interfaces...
==> homestead-7: Mounting shared folders...
    homestead-7: /vagrant => D:/Homestead/homestead
    homestead-7: /home/vagrant/Code => D:/Test
==> homestead-7: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> homestead-7: flag to force provisioning. Provisioners marked to run always will still run.

Executevagrant ssh

Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-51-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

3 packages can be updated.
0 updates are security updates.


Last login: Fri Mar 31 10:14:43 2017 from 10.0.2.2
vagrant@homestead:~$

Enjoy 🙂

Other Problems

Homestead can not mount shared folders

Error: homestead-7: Unable to mount one of your folders. Please check your folders in Homestead.yaml

In the file Homestead.yaml

folders:
    - map: D:/Test
      to: /home/vagrant/Code

In Windows, you should write your directory as Disk_Indicator:/your_path_to_dir

    分享到:
分类: Web Dev

2 条评论

Install Laravel Homestead on Fedora 26 – TripleZ · 2017年9月1日 下午2:31

[…] the former post, download the virtualbox.box file […]

Install Laravel Homestead on Linux – TripleZ · 2017年8月31日 上午11:43

[…] the former post, download the virtualbox.box file […]

Install Laravel Homestead on Fedora 26 – TripleZ进行回复 取消回复

电子邮件地址不会被公开。 必填项已用*标注

验证码 *