系統Windows10
Vagrant 1.8.1
VirtualBox 5.0.20
vagrant box下載地址:http://cloud.centos.org/centos/7/vagrant/x86_64/images/
第1、添加vagrant box
命令:vagrant box add 名稱 box地址
說明:box我放在了,f:/vagrant下因此cmd進入到f:/vagrant下,執行 vagrant box add centos7-x86_64-php7 ./CentOS-7-x86_64-Vagrant-1708_01.VirtualBox.box
第2、執行初始化
命令 vagrant init,這時會生成一個Vagrantfile文件,打開編輯下
第3、啓動vagrant
命令 vagrant up
可能會出現的問題
1)"rsync" could not be found on your PATH. Make sure that rsync is properly installed on your system and available on the PATH.
解決辦法:打開C:\Users\Administrator\.vagrant.d\boxes\centos-6.7-x86_64-php7\0\virtualbox\Vagrantfile
Vagrant.configure("2") do |config|
config.vm.base_mac = "5254007a695a"
config.vm.synced_folder ".", "/vagrant", type: "rsync"
end
修改成:
Vagrant.configure("2") do |config|
config.vm.base_mac = "5254007a695a"
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
end
2)Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant
The error output from the last command was:
mount: unknown filesystem type 'vboxsf'
解決辦法:vagrant plugin install vagrant-vbguest
到此,算是完成了vagrant box的安裝。接下來就是配置開發環境了
設置yum 源爲阿里雲
因爲默認的centos裏面沒有wget,因此先yum install wget
第一步:備份你的原鏡像文件,以避免出錯後能夠恢復。
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
第二步:下載新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
更改CentOS-Media.repo使其爲不生效:
enabled=0
第三步:運行yum makecache生成緩存
yum clean all
yum makecache
原文:https://blog.csdn.net/sobeautiy/article/details/78020962
php