Build win10 + VirtualBox + Vagrant + Homestead heavyweight environment

  1. Download and install VirtualBox

Circumstances may arise can not be installed (critical error)
refer to the following article immediately rollback the installation virtualbox is almost complete, and prompted to install a critical error

PS: the above methods are tested useless QAQ, and finally the time of installation, do not choose to install "bridge network" function after successful, this function should theoretically affect only bridging function, temporarily should not have access, first make do with it . . .

  1. Download and install Vagrant
  2. Download and install GIT
  3. Download Homestead.box file (online download slower)
  4. Use cmd performed at a packet path Homestead.box
// 将Homestead.box包放入vagrant进行管理
vagrant box add laravel/homestead F:/homestead/homestead.box

// 查看包是否安装完成
vagrant box list
  1. Pull configuration script from the file github and generates Homestead.yaml
git clone https://github.com/laravel/homestead.git Homestead

// 进入文件夹
cd Homestead
// 切换最新版本(release中的最近版本)
git checkout v10.2.0

// 生成Homestead.yaml文件
init.bat

Homestead.yaml file is used to indirectly modify Vagrantfile file because the file is referenced Vagrantfile file Homestead.yaml

  1. Modify SSH keys

Used to implement SSH password-free log mirror BOX, modify the following file Homestead.yaml

keys:
    - ~/.ssh/id_rsa
    - ~/.ssh/id_rsa.pub

Type the command: ssh-keygen -t rsa -C "[email protected]"quotation marks are registered your mailbox on github, and then set your ssh password (carriage return has been on the line, because the local connection can not set a password)
PS: If you have ~ / .ssh / id_rsa files, you It does not require a regeneration (where ~ represents the home directory)

  1. Configure shared folders

folders properties Homestead.yaml file lists all the files in the shared folder and Homestead environment. These files are in the folder are subject to change, they stay in sync between local machine and Homestead environment. You can configure multiple shared folders:

folders:
    - map: d:/code
      to: /home/vagrant/Code
# map 对应的是我们本机的文件夹
# to 对应的是 Homestead 上的文件夹
  1. Homestead.box locally installed version number defaults to 0, in order to prevent homestead.box automatic updates, modify the minimum needed to update the version number Homestead / scripts / homestead.rb 0
// 版本号大于等于0的情况下不更新
config.vm.box_version = settings["version"] ||= ">= 0"
  1. Test Run
cd ~/Homestead & vagrant up

Here Insert Picture Description

  1. Test folder synchronization
// 通过 SSH 登录 vagrant(需要先启动 vagrant)
vagrant ssh

// 进入虚拟机的同步文件夹
cd /home/vagrant/code

// 查看文件
ls

// 新建文件
touch aaa.html

After observing d: / aaa.html whether generated code files

Similarly in d: / code under the new bbb.php file to see if the file is generated within a virtual machine

  1. HOMESTEAD use the domain name to access the virtual host

Edit Homestead.yaml file

sites:
    - map: mushishi.com
      to: /home/vagrant/code/public
      
      // 默认没有php这个配置,如果vagrant up的时候出出现PHP版本问题,且无法登陆域名502,则可以尝试追加
      php: "7.2"            

Note: After every time we make a change to Homestead.yaml file, you need to run the following command to make the changes take effect:

// 在虚拟主机开启的情况下(vagrant up之后)
vagrant provision
vagrant reload

Create a test file index.php under / home / vagrant / code / public

phpinfo();

C: \ Windows \ System32 \ drivers \ etc \ hosts add domain names under

// IP和Homestead.yaml中一致
192.168.10.10 mushishi.com

Here Insert Picture Description

  1. Configure global variables (Edit ~ / .bash_profile)
// 编辑文件(vim 是安装git之后有的命令,用git-bash输入这个命令)
vim ~/.bash_profile

Use vim Reference: vim Editor Description

// 输入以下内容
function homestead() {
    ( cd ~/homestead && vagrant $* )
}
// 保存后重新加载文件
source ~/.bash_profile

Use homestead anywhere test command

// 等效于vagrant up
homestead up
  1. Database Connectivity

MySql default account and password at Homestead
Username: homestead
Password: secret

Homestead local connection configuration database
Here Insert Picture Description

Published 40 original articles · won praise 0 · Views 772

Guess you like

Origin blog.csdn.net/qj4865/article/details/104283161
Recommended