vagrant box php開發環境配置--vagrant安裝

公司的電腦安裝的是win10的操做系統,可是部署的環境是centos,因此,爲了在開發完成後不出現由於開發環境產生的問題,決定在開發環境種使用個vagrant的centos box,和生產環境一致。php

Virtualbox安裝

下載最新版本的virtualbox for windows x64,5.1.8 下載頁html

vagrant

下載vagrant for windows 1.9.3 下載頁shell

安裝完畢vagrant須要重啓計算機vim

centos7 box下載

vagrant box add centos/7

選擇 provider virtualbox 通常下載會很是慢,甚至中途斷開鏈接,因此直接ctrl + c,中斷下載,複製連接,直接用迅雷加速下載 下載完畢後windows

vagrant box add centos7  box_url # box_url 爲box本地保存地址

共享目錄方案選擇

vagrant在host和box之間共享文件夾有多種方案,centos官方推薦nfs,不過我不喜歡在windows上在安裝一個nfs server(由於開發目錄要在host上),仍是用virtualbox的 VirtualBox Guest Additions 修改目錄C:\Users\yourname.vagrant.d\boxes\centos7\0\virtualbox下的Vagrantfilecentos

config.vm.synced_folder ".", "/vagrant", type: "virtualbox"

而後安裝插件ssh

vagrant plugin install vagrant-vbguest

工做目錄初始化

mkdir workspace\phptest
vagrant init centos7

ssh

我習慣用xshell來ssh登陸,host是127.0.0.1,端口使用端口轉發,默認是2222,用戶名vagrant,密碼vagrant,key直接選擇文件,工做目錄下面找private_key文件ide

開發環境直接改成密碼登陸。登陸後,url

sudo vim /etc/ssh/sshd_config

修改以下centos7

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
PermitEmptyPasswords no
#PasswordAuthentication no
相關文章
相關標籤/搜索