Laravel Learning under Windows Homestead Environment Construction

Source: Internet
Author: User
Tags hhvm virtual environment

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:
    1. 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:
    1. 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
    1. 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
    1. 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
    1. ssh-keygen -t rsa -C "[email protected]"
c. Enter the Homestead folder from the window console and execute the following initialization command
    1. 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
  1. ---
  2. #虚拟机IP
  3. ip:"192.168.10.10"
  4. #虚拟机内存大小
  5. memory:2048
  6. #虚拟机cpu数量
  7. cpus:1
  8. #提供虚拟机类型
  9. provider: virtualbox
  10. #公钥SSH KEY
  11. authorize:~/.ssh/id_rsa.pub
  12. #私钥SSH KEY
  13. keys:
  14. -~/.ssh/id_rsa
  15. #共享文件夹
  16. folders:
  17. - map: D:\Xampp\htdocs\blog #自己电脑上的项目路径
  18. to:/home/vagrant/Code#映射到虚拟机中的路径
  19. #站点配置web服务器配置
  20. sites:
  21. - map: homestead.app #域名
  22. to:/home/vagrant/Code/blog/public #域名的映射地址
  23. #数据库配置
  24. databases:
  25. - homestead
  26. # blackfire:
  27. # - id: foo
  28. # token: bar
  29. # client-id: foo
  30. # client-token: bar
  31. # ports:
  32. # - send: 50000
  33. # to: 5000
  34. # - send: 7777
  35. # to: 777
  36. # protocol: udp
d. Start the test
① If the configuration item is not modified execute the following command
    1. 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
    1. vagrant up --provision
E. Testing
①ssh Test: Now Windows console input
    1. 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
    1. http://localhost:8000/
Add the following code to the C:\Windows\System32\drivers\etc\hosts
  1. # Copyright (c) 1993-2009 Microsoft Corp.
  2. #
  3. # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
  4. #
  5. # This file contains the mappings of IP addresses to host names. Each
  6. # entry should be kept on an individual line. The IP address should
  7. # be placed in the first column followed by the corresponding host name.
  8. # The IP address and the host name should be separated by at least one
  9. # space.
  10. #
  11. # Additionally, comments (such as these) may be inserted on individual
  12. # lines or following the machine name denoted by a ‘#‘ symbol.
  13. #
  14. # For example:
  15. #
  16. # 102.54.94.97 rhino.acme.com # source server
  17. # 38.25.63.10 x.acme.com # x client host
  18. # localhost name resolution is handled within DNS itself.
  19. #127.0.0.1 localhost
  20. #::1 localhost
  21. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.