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
相关文章
相关标签/搜索