Detailed tutorial for installing the homestead development environment under window

  • 2020-05-17 06:58:40
  • OfStack

1. Resource preparation

Link: http: / / pan. baidu. com s / 1 mh7qUBe password: p4wx

1. virtualbox.box files are located in the C root directory.

2. metadata.json files are placed in the C disk user directory. For example, mine is C:\Users\pc

3. Git-2.9.3-64-bit-exe download and install, all by default.

4. vagrant_1.8.5.msi download and install.

5. VirtualBox-5.1.4-110228-Win.exe download and install.

2. Introduction

1. What is vagrant?

VirtualBox believe that a lot of people are used, it is a virtualization software, used to on a computer in our virtual out 1, and VMware Workstation, kvm, xen is 1 kind things such as the term is Hypervisor (professional), but it provides easy-to-use interface (also have VMware), support for the platform (Linux Win, Mac), and very light weight, the most critical free ah, so very widely used.

We usually use VirtualBox one of the most common situation is that your computer is a Win, want to run a Linux, or a computer is a Linux, run win on net silver, what QQ win only, although there are wine such things, can run under Linux win software, but there's a win system stability is not better, and now the computer configuration, completely don't have to worry about virtual machine consumes memory CPU what of, you don't have to it is a waste? And VirtualBox is so light. Personal experience, get an xp virtual machine run. QQ consumes less resources than chrome or ff on webQQ.

For code code helpless pain everyday programmer can't VirtualBox is simply hang a Q, so programmers make code is code, can do a lot of projects, the company make java, php, oneself home again play a python what of, want to experience the new version of the mongodb or nginx Emacs or vim configuration, guaranteed no which is the last version of the database of project mysql, next version used postgresql, so many things are all in 1, Install on 1 computer, can be made by this all sorts of configuration environment certainly dizzy, vexed greatly vexed.

What can we do, it is best to the development of each project has a clean environment, only for this project, but we would not make every one project with a computer, the virtual machine, 1 for each project with a virtual machine, developing A rev A virtual machine, so that each independent development environment, clean. There is still a problem, our project has multiple developers, how to ensure that everyone's development environment is 1 kind, always can't everyone 1 click the mouse, fill in the configuration parameters, build the last 1 software installation, this is too troublesome, too not geek. What we want is for the environment to be configured only once, and then we can package deliver for someone else, and when they get it, they can use it directly. Is there such a thing? There is, of course, Vagrant. That's what it does.

2. What is homestead?

homestead marks in gray the environment that laravel is officially packaged for us to use, which is the first file p.box in the resource preparation. It contains the following:


Ubuntu 16.04
Git
PHP 7.0
Nginx
MySQL
MariaDB
Sqlite3
Postgres
Composer
Node (With PM2, Bower, Grunt, and Gulp)
Redis
Memcached
Beanstalkd

3. Installation steps

Under the Git bash

1. Enter vagrant box add metadata. json

2. Input git clone https: / / github com/laravel/homestead git Homestead

3. Enter bash init.sh

You will have an homestead folder in your user directory with an Homestead.yaml file, which is the homestead configuration file that we often use in our daily development. Now edit the file


---
# The virtual machine ip address 
ip: "192.168.10.10"
# Allocated virtual memory 
memory: 2048
#cpu The number 
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
# Set the Shared folder between the host and the virtual machine 
folders:
# The host 
- map: ~/Code/test
# The virtual machine 
to: /home/vagrant/Code/test
# Set the domain name and access address 
sites:
- map: test.app
to: /home/vagrant/Code/test/public
# The database 
databases:
- homestead
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp

After editing, create an Code folder in the user directory. Within this folder, create an test folder. The virtual machine ip address is then bound to the domain name. Edit C:\Windows\ drivers\ drivers\etc add 1 line to hosts under 192.168.10.10 test.app. (file permissions may need to be modified to add)

4. Input ssh - keygen

Display: Enter file in which to save the key (/ c/Users/pc /. ssh/id_rsa) :

It doesn't matter if it just hits enter, and then it asks you to enter your password, which is also hit enter.

5. Enter vagrant up

6. Enter vagrant ssh

Now that you're in the virtual machine, create a new Code folder, go into Code and create another test folder.

The ok, homestead development environment has been matched

Enter exit to exit the virtual machine enter vagrant halt to close the virtual machine enter vagrant to view common commands


Related articles: