First, Introduction
1, Homestead
Laravel Homestead is an official pre-packaged vagrant box that provides us with a learning and developer environment where we do not install other software such as Php,hhvm,web servers on our own computers. Do not worry about the environment to build the problem, Vagrant box all will be to solve, we only need to use the good. If there is a problem, we can re-destroy vagrant box to reinstall one.
2. Built-in software
- Ubuntu 16.04
- Git
- PHP 7.0
- HHVM
- Nginx
- Mysql
- MariaDB
- Sqlite3
- Postgres
- Composer
- Node (included with PM2, Bower, Grunt, and Gulp)
- Redis
- Memcached
- Beanstalkd
2, Vagrant
there will be questions about what vagrant is, in fact vagrant is a tool for creating and deploying virtualized development environments. Take VirtualBox for example, VirtualBox will open an interface to create a virtual machine, vagrant will use this interface to create a virtual machine, and vagrant to manage, configure and automatically install the virtual machine.
Second, installation
1, install the virtual machine software Virtaulbox or VM (recommended with Virtaulbox), and then install Vagrant Software. Here are the graphical interface installation, directly attached to the software's current address Virtualbox,vagrant2, install the Homestead box in the Windows console to execute the following command:
vagrant box add laravel/homestead
This command will be downloaded directly from the Internet Homestead box is about 1G, is also a foreign network, so very slow, you can try to download the homestead to download the tool to attach the link:
https://atlas.hashicorp.com/hashicorp/boxes/precise64/versions/1.1.0/providers/virtualbox.box
then execute the following command in the Windows console to bind the local box to Laravel/homestead: where path/to/ Virtualbox.box is the path of the downloaded Virtualbox.box
vagrant box add laravel/homestead /path/to/virtualbox.box
3, installation Homestead
A. If Git is installed on the computer (it is not installed first), Git has a window client installed directly), the Homestead project is cloned directly, the following command
git clone https://github.com/laravel/homestead.git Homestead
b. Git bash terminal into git executes the following command to generate the secret key and public key
ssh-keygen -t rsa -C "[email protected]"
c. Enter the Homestead folder from the window console and execute the following initialization command
bash init.sh
after executing the command, there will be a Homestead.yaml configuration file under the C:\User\UserName\.homestead folder, which can be configured here according to your own requirements, as follows
---
#虚拟机IP
ip:"192.168.10.10"
#虚拟机内存大小
memory:2048
#虚拟机cpu数量
cpus:1
#提供虚拟机类型
provider: virtualbox
#公钥SSH KEY
authorize:~/.ssh/id_rsa.pub
#私钥SSH KEY
keys:
-~/.ssh/id_rsa
#共享文件夹
folders:
- map: D:\Xampp\htdocs\blog #自己电脑上的项目路径
to:/home/vagrant/Code#映射到虚拟机中的路径
#站点配置web服务器配置
sites:
- map: homestead.app #域名
to:/home/vagrant/Code/blog/public #域名的映射地址
#数据库配置
databases:
- homestead
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
d. Start the test
① If the configuration item is not modified execute the following command
vagrant up
you can see the display on the terminal, the following results indicate that the boot is complete
② If you modify a configuration item, you need to execute the following command
vagrant up --provision
E. Testing
①ssh Test: Now Windows console input
vagrant ssh
make an SSH connection, execute the LS command to see if there is a mapped folder
② Browser access to virtual machine site testing
http://localhost:8000/
Add the following code to the C:\Windows\System32\drivers\etc\hosts
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#‘ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
#127.0.0.1 localhost
#::1 localhost
192.168.10.10 homestead.app
access in the browser
③, the data connection test is connected by the Local connection tool (where Navicat is used to connect), the username is Homestead password is secret
Iii. SummaryHomestead is a very useful virtual environment, but for those who have not been exposed to these things may feel strange, will also tread a lot of pits, but also will play more and more interested. Feel the laravel of the ecological circle more and more perfect, laravel more and more fascinated, hope and small partners to learn to communicate, the back will be more new records of their own pits and some solutions.
Laravel Learning under Windows Homestead Environment Construction