1 安装 VirtualBox
2 安装 Vagrant
3 把下载的Homestead Box,比如我通过百度网盘,百度网盘默认安装在D盘,
直接在百度网盘文件夹下解压缩,然后在Windows的cmd命令提示符下
Microsoft Windows [版本 10.0.18363.1198]
(c) 2019 Microsoft Corporation。保留所有权利。
C:\Users\T15>d:
D:\>cd BaiduNetdiskDownload
D:\BaiduNetdiskDownload>cd lc-homestead-8.2.1-2019112300
D:\BaiduNetdiskDownload\lc-homestead-8.2.1-2019112300>vagrant box add metadata.json
然后回车键。
4 安装 Git,安装完毕后,在电脑桌面上,鼠标右键,选择Git Bash Here
5 接下来,使用 Git 下载定制版的 Homestead
> cd ~
> git clone https://gitee.com/summerblue/homestead.git Homestead
//这里我们使用 v7.8.0
> cd ~/Homestead
> git checkout v7.8.0
//初始化 Homestead;系统提示:Homestead initialized!,表示初始化完成
> bash init.sh
初始化完成后,趁热打铁
> vi ~/Homestead/Homestead.yaml
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
- ~/.ssh/id_rsa.pub
folders:
- map: ~/Code
to: /home/vagrant/Code
sites:
- map: homestead.test
to: /home/vagrant/Code/Laravel/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
//使用以下方法来生成 SSH Key,请将 your_email@example.com 替换为你的邮箱:
> ssh-keygen -t rsa -C "your_email@example.com"
然后回车回车,
如果提示Overwrite (y/n)?
则 y
然后回车、回车、回车
然后记得修改hosts
这里我们使用记事本
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.test
192.168.10.10 blog.test
让我们开始启动 Homestead:
> cd ~/Homestead && vagrant up
> vagrant ssh
在这里,需要升级一下composer
vagrant@homestead:~$ cd ~
vagrant@homestead:~$ composer self-update
Updating to version 2.0.7 (stable channel).
Downloading (100%)
Use composer self-update --rollback to return to version 1.9.0
$mkdir Code
cd Code
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
cd ~/Code
composer create-project laravel/laravel Laravel --prefer-dist "6.*"
接下来是对Git进行设置
首先我们对 Git 进行用户名和邮箱进行设置,请参照下面格式,替换为你自己常用的用户名和邮箱来完成设置:
$ git config --global user.name "Your Name"
$ git config --global user.email your@example.com
接下来设置 Git 推送分支时相关配置:
$ git config --global push.default simpleCopy
此设置是 Git 命令 push 的默认模式为 simple,当我们执行 git push 没有指定分支时,自动使用当前分支,而不是报错。
1、对 Git 进行初始化:
$ cd ~/Code/Laravel
$ git init
2、将项目所有文件纳入到 Git 中:
$ git add -A
我们可以通过在 .gitignore 文件中进行设置,来选择忽略掉一些我们不想纳入到 Git 版本管理中的文件(如缓存文件)。
3、检查 Git 状态:
$ git status
4、保留改动并提交:
$ git commit -m "Initial commit"
接下来是
一些,其它配置项目
-----------------------------------
接下来将 SSH Key 添加到 ssh-agent 中:
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa
> cat ~/.ssh/id_rsa.pub
-----------------------------------
其它
.gitignore
$ cd ~/Code/Laravel
$ git remote add origin git@github.com:your_username/hello_laravel.git
$ git push -u origin master
$ vagrant box list
lc/homestead (virtualbox, 8.2.1)