一、安装VirtualBox
点击(https://www.virtualbox.org/wiki/Downloads),下载安装包。安装过程可能失败,是由于电脑阻止了,打开电脑的 系统偏好设置---->安全性与隐私---->通用。会出现个 oracl.... 的一个选项,点允许就可以安装了
二、安装Vagrant
输入命令安装
brew tap hashicorp/tap
brew install vagrant
注:我安装的过程中出现了
fatal: unable to access 'https://github.com/hashicorp/homebrew-tap/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
解决:
git config --global --unset http.proxy
git config --global --unset https.proxy
三、安装 Homestead Vagrant Box
vagrant box add laravel/homestead
四、安装Homestead
git clone https://github.com/laravel/homestead.git Homestead
注:安装的过程中一直出现错误
fatal: unable to access 'https://github.com/laravel/homestead.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
解决方法:
先关掉代理,运行下面命令
git config --global --unset http.proxy
git config --global --unset https.proxy
执行完上述命令即可安装成功,继续
cd Homestead
bash init.sh
注:使用 bash init.sh 命令来生成 Homesstead.yaml 文件以及after.sh和aliases文件。映射文件夹,数据库名,域名映射关系等都在这里配置。根据自己的需要配置。
1、配置共享文件
folders:
- map: ~/code
to: /home/vagrant/code
注:map 对应本地的,to对应虚拟机服务器上的。可以配置多个。
2、站点nginx配置
sites:
- map: larabbs.app
to: /home/vagrant/code/larabbs/publicå
注:map 对应的是域名,to对应的是服务器文件位置。因为上边文件夹的映射关系,其实代码在本地就可以了。
五、启动
vagrant init
vagrant up
注:启动过程中出现错误
Check your Homestead.yaml (or Homestead.json) file, the path to your private key does not exist.
原因:没有生成本地密钥
解决方法:
cd ~/.ssh
ssh-keygen
然后修改Homestead里面的Homestead.yaml配置,id_rsa换成你自己的密钥名称
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
再次启动成功
网友评论