Home  >  Article  >  PHP Framework  >  How to install and build Homestead 2.0 environment on Mac

How to install and build Homestead 2.0 environment on Mac

青灯夜游
青灯夜游forward
2021-12-23 11:08:382161browse

How to set up a Homestead environment on Mac? The following article will introduce to you how to install and build the Homestead 2.0 environment under the Mac version. I hope it will be helpful to you!

Homestead is one of Laravel's officially recommended development environments. It consists of a Homestead script that customizes VagrantHow to install and build Homestead 2.0 environment on Mac and a Vagrant box that contains PHP development-related software.

Note: This document is a note on installing Homestead 2.0 under Mac version 10.10. It requires a certain understanding of Homestead when reading. For instructions on Homestead, please see (https://learnku.com/laravel/ t/256).

Installation

1. Install Virtual Box

##Download (https://www.virtualbox.org/wiki/ Downloads) and install Virtual Box.

2. Install Vagrant

Download (http://www.vagrantup.com/downloads.html) and install Vagrant.

3. Download and add homestead box

Command line operation

$ vagrant box add laravel/homestead
Output

How to install and build Homestead 2.0 environment on Mac

In order to speed up the download, CTRL C interrupts the download and uses the multi-threaded download tool to download the link pointed to by cutting off the image above.

After downloading, execute the following command to modify /path/to/ virtualbox.box is the correct path.

$ vagrant box add laravel/homestead /path/to/virtualbox.box

4. Install homestead command

composer global require "laravel/homestead=~2.0"
Please make sure

~/. The composer/vendor/bin directory is in your PATH.

After the installation is complete, execute the following command to test:

homestead
Configuration and initialization

1. Initializing homestead

$ homestead init
will generate

~/.homestead/Homestead.yaml How to install and build Homestead 2.0 environment on Mac

2. Configure Homestead.yaml

Run the following command to edit the

~/.homestead/Homestead.yaml How to install and build Homestead 2.0 environment on Mac

$ homestead edit
Save after modification :


How to install and build Homestead 2.0 environment on Mac

3. Add hosts

Execute the following command

$ sudo vi /etc/hosts
Append

192.168.10.10    phphub.app

4. Initialize the homestead virtual machine

$ homestead up
After the initialization is completed, visit the browser http://phphub.app

Other information

Port mapping

Local address

127.0.0.1Port corresponding

    SSH: 2222 → Forwards To 22
  • HTTP: 8000 → Forwards To 80
  • MySQL: 33060 → Forwards To 3306
  • Postgres: 54320 → Forwards To 5432

Connect to the database

The authentication for MySQL and Postgres is: homestead/secret

Log in to the virtual machine

$ homestead ssh

                                                                                                           

The above is the detailed content of How to install and build Homestead 2.0 environment on Mac. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete