Windows Installation mode

Online installation

Box download address: vagrantcloud.com/laravel/box…

vagrant box add laravel/homestead

There are four options for you to choose from. So the varant box we’re going to use is 3

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

Downloading online takes too long, so choose manual installation


The local installation

Methods a

Step one:

> vagrant box add metadata.json
Copy the code

Metadata. json contains the following content:

{
    "name": "laravel/homestead"."versions": [{"version": "7.1.10"."providers": [{"name": "virtualbox"."url": "virtualbox.box"}]}]}Copy the code

Step 2:

Run the following command to go to the Homestead management script directory: >cdHomestead creates a new virtual machine using the following command: > Vagrant upCopy the code

Way 2

> vagrant box add laravel/homestead d:/code/homestead.box
Copy the code

The default location for storing the box image: take my computer as an example: C:\Users\mengy.vagrant.d\boxes

Install the Homestead management script
Suppose the path is at E:\ Vagrant \ HomesteadcloneManagement script# git clone https://github.com/laravel/homestead.git
# cd HomesteadBecause the master is unstable, cut to the labeled stable version# git checkout v7.18.0	To create the Homestead.yaml configuration file in E: vagrant Homestead Homestead#init.bat (double click on window)#bash init.shNote: Because homestead.box is locally installed as version 0, So you need to modify the configuration file E:\vagrant\homestead\homestead\scripts\homestead. Rb config.vm.box_version = Settings ["version"] | | ="> = 0"Run the following command to create a new VM:# vagrant up
Copy the code

Log in using the SSH private key

Modify the following contents of the homestead. yaml file to implement SSH password-free login:
Keys: -c :/Users/mengy/. SSH /id_rsa -c :/Users/mengy/. SSH /id_rsa.pub Git Bash Here ssh-keygen -t rsa -c"[email protected]"
    
    Press Enter to set the password
Copy the code

Configuring a Shared Folder

Folders in the Homestead. Yaml file list all folders shared with the Homestead environment. If files in these folders change, they keep the local machine synchronized with the Homestead environment. You can configure multiple shared folders as needed:
folders:
    - map: E:/vagrant/code
      to: /home/vagrant/code
      
# map corresponds to our local folder
# to corresponds to the Homestead folder
# type This will speed up loading
Copy the code

Vagrant command

If you add the --provision option, the new site will be published to the virtual machine.
vagrant up
# close
vagrant halt
# Log in to Vagrant via SSH (you need to start Vagrant first)
vagrant ssh
View a list of boxes currently installed
vagrant box list
# delete box image
vagrant box remove laravel/homestead
# Delete a VM
vagrant destroy
# Check the status of the Homestead VM.
vagrant status
Copy the code

Homestead configuration changes need to be reloaded

# vagrant reload --provision
Copy the code

SSH Connection

You can now log on to the Homestead virtual host, where you can view the synchronization between the local directory defined above and the virtual machine directory

vagrant ssh

Use Xshell to connect to SSH

The username and password are both vagrant

The database

To connect to MySQL from the host’s database client, connect to 127.0.0.1 and port 3306 (MySQL).

The username and password are Homestead/secret.

PHP program connection (virtual machine connection) port 3306

Redis client connection

Modify the redis configuration file (default path /etc/redis/redis.conf)

Requirepass yourPassword ---- Set any password you wantbind127.0.0.1 is modified tobind 0.0.0.0
Copy the code

After modifying the configuration, restart Redis and run the redis command

sudo service redis restart
Copy the code

Viewing the Modification

$# ps -ef | grep redis
Copy the code

Modify port forwarding for homestead. yaml files, and then run Vagrant Reload –provision to restart the virtual machine

ports:
      - send: 63790
        to: 6379
Copy the code

Use Redis Desktop Manager to connect to Redis

Connection Settings: Name: Homestead Address: 192.168.10.10:63790 Authentication: HomesteadCopy the code

The response is slow

Fixed WINDOS Homestead slowdowns

Be sure to back up first

First, the command line enters Homestead to start Vagrant

> cd ~/Homestead && vagrant up
Copy the code

Then run the install command (if the download fails, it may be blocked)

$ vagrant plugin install vagrant-winnfsd
Copy the code

Modify the file 1: favored/scripts/favored rb

Find this code, which may be slightly different, and replace it with the following

if settings.include? 'folders'
  settings["folders"].sort! { |a,b| a["map"].length <=> b["map"].length }

  settings["folders"].each do |folder|
    config.vm.synced_folder folder["map"], folder["to"], 
    id: folder["map"],
    :nfs => true,
    :mount_options => ['nolock,vers=3,udp,noatime']
  end
end
Copy the code

File 2: homestead.yaml

folders:
    - map: ~/Code
      to: /home/vagrant/Code
      type: nfs
Copy the code

Restart Homestead for the configuration file to take effect, and you’re done.