vagrant box php開發環境配置 -- 從新打包發佈vagrant box

如今基本差很少了,能夠從新打包發佈了php

打包

Usage: vagrant package [options] [name|id]

Options:

        --base NAME                  Name of a VM in VirtualBox to package as a base box (VirtualBox Only)
        --output NAME                Name of the file to output
        --include FILE,FILE..        Comma separated additional files to package with the box
        --vagrantfile FILE           Vagrantfile to package with the box
    -h, --help                       Print this help

打開virtualbox看一下虛擬機實例的名字: phptest_default_1490589998754_16798 而後打包node

vagrant package --base phptest_default_1490589998754_16798 -output centos7_php7.box

等待一下子,一個你定製好的vagrant box打包好了git

你可能還有其餘的軟件須要提早安裝,好比redis,好比nodejs,能夠參照個人另外一篇博客CentOS 7 安裝 gitlab 8.1.7github

可能遇到的問題

  1. ssh private key

Warning: Authentication failure. Retrying... 這個問題的緣由是vagrant在初始化時虛擬機實例時,若是發現insecure key,會自動生成新的key pair去替換掉默認的,打包時把新的public key打包進box。這樣使用該包生成新的實例時,和默認的insecure key就不匹配了。解決方案就是在打包以前,把虛擬機中的的public key從新替換秤默認的。redis

cd /home/vagrant
sudo -u vagrant wget https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -O .ssh/authorized_keys

這時不要關閉虛擬機,把 .vagrant\machines\default\virtualbox目錄下的private_key文件刪除 在host系統上執行centos

vagrant package

這樣就能夠了。 還有些很是規解決方案,好比,修改ssh登陸時使用用戶名密碼對等,php7

config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
  1. 以前配置的端口映射須要從新配置

解決方案就是把相應的Vagrantfile打包進來ssh

vagrant package --base xx --output centos7_php7 --vagrantfile xx
相關文章
相關標籤/搜索