1. Environmental requirements

1, MAC M1

This is your M1 MAC.Copy the code

MacOS Big Sur 11.3.1 or above

Upgrade the system after 11.3.1Copy the code

Here is my system:

Parallels Desktop 16 for Mac

Go to the official website to download the address given:

www.parallels.com/products/de… Click Download, and when the download is complete, run install the.dmg suffix.

There is a charge for this, but the vagrant-Parallels we used later is free.

4, Vagrant 2.2.15

Address:

www.vagrantup.com/downloads

Click download. After the download is complete, run install the.dmg suffix.

After downloading, run the command on the terminalvagrant -vIf the following figure is displayed, the installation is successful:

Install Homestead and the vm

Install Homestead

Run the following commands on the terminal one by one:

  1. sudo git clone https://github.com/laravel/homestead.git ~/Homestead
  2. sudo cd ~/Homestead
  3. sudo git checkout release
  4. sudo bash init.sh

We opened Homestead in VScode and made the following changes:

Save.

Install the arm architecture Vagrant Box

Tips: The following commands are also run in the Homestead folder.Copy the code
  1. The installationvagrant-parallelsThe command:sudo vagrant plugin install vagrant-parallels

As shown, the installation is successful:

  1. downloadarmThe architecture of thevagrant boxThe website is as follows:

https://app.vagrantup.com/yodoware/boxes/homestead-arm64Pull the end:When you download it, rename it toparallels.box. In 7.HomesteadNew under filemetadata.jsonWrite the following code:

{
    "name": "laravel/homestead"."versions": [{
        "version": "11.3.0"."providers":[
            {
            "name": "parallels"."url": "/Users/justin/Downloads/parallels.box"}}}]]Copy the code

The URL must be changed to the location of the path you just downloaded and renamed Parallels. Box. You don’t need to change your Downloads if you are one of them. Of course Justin would have to be your own.

  1. Execute command:sudo vagrant box add metadata.json

Create the ARM architecture Vargant Box. 9. Runsudo vagrant upThe vm is successfully run as follows:

  1. performsudo vagrant sshEnter, the following is successful:

At this pointm1Set upHomesteadThe development environment is complete.

Three, the effect test

You can see this line of codehomestead1: /home/vagrant/code => /Users/justin/codeCan know in the local /Users/justin/codeWith the virtual machine/home/vagrant/codeKeep the files synchronized when they have changed. We can test: in the virtual machine to entercodeCreate folder file test command:touch test: Let’s see if we can synchronize it locally:You can see that the local synchronization has been done, indicating that our environment is set up correctly.

Four, step pit record

Parallels Desktop virtual machine with the name ‘homestead’ already exists.

Please use another name or delete the machine with the existing name, and try again

If the above error is reported, it may be becauseParallels Desktop, you have created a virtual machine with the same name, you can use the command:sudo vagrant box listView all VMS:You can use the command:Sudo Vagrant Box Remove Laravel/Homestead (this is your vm name)To remove the virtual machine. If you remove it, thensudo vagrant upI don’t know exactly how to solve it, but we can look at the source code when it runs, inHomestead\scripts\homestead.rb: Let’s change a few names: a different name will solve this problem and start the virtual machine. :In asettings['hostname']I’m going to replace them.

Vagrant common command

Sudo Vagrant Box List: View all virtual machines. Sudo vagrant global-status: Displays the VM status. Sudo Vagrant Box Remove VM name: Remove the VM. Sudo vagrant Destroy VM ID: Destroy the VM. Sudo Vagrant Box Add VM: Creates a VM. Sudo vagrant up: Start the VIRTUAL machine. Sudo vagrant reload –provision: Indicates that the Settings are modified and the VM is restarted.

Vi. Install Laravel on the VM and test it locally

In the virtual machinecodeRun the laravel project command in the directory:composer create-project --prefer-dist laravel/laravel shopApi

After the installation is complete, you can see the following:Then changehomestead.yaml:Since we have modified the configuration file, we open a new terminal to enterHomesteadRun the following command:sudo vagrant reload --provisionRestart the VM:And then in\etc\hostWrite the domain name mapping:Then open it with browsehttp://homestead.test/As you can seelaravelIt is already running, and the beautiful picture is as follows:

Here’s a summary of all the pits m1 built for Homestead, in the hope that it can help you. If you find this post helpful, please comment on it for 3 times. Thank you. Your post is definitely another support for my blogging.