1. Resource preparation
Link: http://pan.baidu.com/s/1mh7qUBe Password: p4wx
1. The virtualbox.box file is placed in the root directory of drive C.
2. The metadata.json file is placed in the user directory of the C drive. For example, mine is C:Userspc
3. Download and install Git-2.9.3-64-bit.exe, just leave everything as default.
4. Download and install vagrant_1.8.5.msi.
5. Download and install VirtualBox-5.1.4-110228-Win.exe.
2. Introduction
1. What is vagrant?
VirtualBox I believe many people have used it. It is a virtualization software that is used to virtualize a computer on our computer. It is the same type of thing as VMware Workstation, kvm, xen, etc. (the professional term is called Hypervisor), but it provides an easy-to-use interface (VMware also has it), supports various platforms (Linux, Win, Mac), is very lightweight, and the most important thing is free, so it is very widely used.
The most common situation when we usually use VirtualBox is that our computer is Win and we want to run Linux, or our computer is Linux and we want to run Win online banking, QQ or something like win only, although there are things like wine , you can run software under win under Linux, but wouldn’t the stability of a win system be better? And with the current computer configuration, you don’t have to worry about the virtual machine consuming memory and CPU. It would be a waste if you don’t use it, not to mention VirtualBox So lightweight. Personal experience, running QQ on an . .
的 For the hard -working programmers of the Tiantian Code, VirtualBox cannot simply hang up a Q to use it. java, php, go home and play python or something. I want to experience the configuration of the new version of mongodb or nginx, Emacs or vim. I am not sure which project has mysql as the database in the previous version. I will use it in the next version. After installing postgresql, with so many things all put together and installed on one computer, you will definitely be confused and annoyed by the various configuration environments.What should I do? It is best to have a clean development environment for each project, just for this project, but we cannot match a computer for each project. With, the virtual machine, to each project with a project with a project Virtual machine, when developing A, start A's virtual machine, so that each development environment is independent of each other and clean. There is another question. Our project has multiple developers. How do we ensure that everyone has the same development environment? We cannot just click the mouse one by one, fill in the configuration parameters, and then install the software one by one after it is built. This It’s too cumbersome and not geeky. What we want is that the environment only needs to be configured once, and then the environment can be packaged and delivered to others. After others get it, they can start it and use it directly. Is there such a thing? There must be, Vagrant, it is used for this.
2. What is homestead?
Homestead marks in red above the environment that laravel is officially packaged for us to use, which is the first file virtualbox.box in the resource preparation. It contains the following things: 3. Installation steps Git bash download 1. Enter vagrant box add metadata.json 2. Enter bash init.sh
At this time, there will be an additional .homestead folder in your user directory, which contains a Homestead.yaml file. This is the homestead configuration file, which we often use in daily development. Edit this file now
4. Enter ssh-keygen
Ignore it and just press Enter. Then you will be asked to enter your password, and you will also press Enter directly.
5. Enter vagrant up
6. Enter vagrant ssh
<span class="token operator">git clone https<span class="token punctuation">:<span class="token operator">/<span class="token operator">/github<span class="token punctuation">.com<span class="token operator">/laravel<span class="token operator">/homestead<span class="token punctuation">.git Homestead</span></span></span></span></span></span></span></span>
<span style="color: #008080;"> 1</span> ---
<span style="color: #008080;"> 2</span> <span style="color: #000000;">#虚拟机的ip地址
</span><span style="color: #008080;"> 3</span> ip: <span style="color: #800000;">"</span><span style="color: #800000;">192.168.10.10</span><span style="color: #800000;">"</span>
<span style="color: #008080;"> 4</span> <span style="color: #000000;">#分配给虚拟的内存
</span><span style="color: #008080;"> 5</span> memory: <span style="color: #800080;">2048</span>
<span style="color: #008080;"> 6</span> <span style="color: #000000;">#cpu数
</span><span style="color: #008080;"> 7</span> cpus: <span style="color: #800080;">2</span>
<span style="color: #008080;"> 8</span> <span style="color: #000000;">provider: virtualbox
</span><span style="color: #008080;"> 9</span>
<span style="color: #008080;">10</span> authorize: ~/.ssh/<span style="color: #000000;">id_rsa.pub
</span><span style="color: #008080;">11</span>
<span style="color: #008080;">12</span> <span style="color: #000000;">keys:
</span><span style="color: #008080;">13</span> - ~/.ssh/<span style="color: #000000;">id_rsa
</span><span style="color: #008080;">14</span>
<span style="color: #008080;">15</span> <span style="color: #000000;">#设置主机与虚拟机的共享文件夹
</span><span style="color: #008080;">16</span> <span style="color: #000000;">folders:
</span><span style="color: #008080;">17</span> <span style="color: #000000;"> #主机
</span><span style="color: #008080;">18</span> - map: ~/Code/<span style="color: #000000;">test
</span><span style="color: #008080;">19</span> <span style="color: #000000;"> #虚拟机
</span><span style="color: #008080;">20</span> to: /home/vagrant/Code/<span style="color: #000000;">test
</span><span style="color: #008080;">21</span> <span style="color: #000000;">#设置域名与访问地址
</span><span style="color: #008080;">22</span> <span style="color: #000000;">sites:
</span><span style="color: #008080;">23</span> -<span style="color: #000000;"> map: test.app
</span><span style="color: #008080;">24</span> to: /home/vagrant/Code/test/<span style="color: #0000ff;">public</span>
<span style="color: #008080;">25</span> <span style="color: #000000;">#数据库
</span><span style="color: #008080;">26</span> <span style="color: #000000;">databases:
</span><span style="color: #008080;">27</span> -<span style="color: #000000;"> homestead
</span><span style="color: #008080;">28</span>
<span style="color: #008080;">29</span> <span style="color: #000000;"># blackfire:
</span><span style="color: #008080;">30</span> # -<span style="color: #000000;"> id: foo
</span><span style="color: #008080;">31</span> <span style="color: #000000;"># token: bar
</span><span style="color: #008080;">32</span> # client-<span style="color: #000000;">id: foo
</span><span style="color: #008080;">33</span> # client-<span style="color: #000000;">token: bar
</span><span style="color: #008080;">34</span>
<span style="color: #008080;">35</span> <span style="color: #000000;"># ports:
</span><span style="color: #008080;">36</span> # - send: <span style="color: #800080;">50000</span>
<span style="color: #008080;">37</span> # to: <span style="color: #800080;">5000</span>
<span style="color: #008080;">38</span> # - send: <span style="color: #800080;">7777</span>
<span style="color: #008080;">39</span> # to: <span style="color: #800080;">777</span>
<span style="color: #008080;">40</span> # protocol: udp
bind the virtual machine IP address and domain name. Edit the hosts under the file C:WindowsSystem32driversetc and add a line: 192.168.10.10 test.app. <span class="token punctuation">(You may need to modify the file permissions to increase it)</span>