• Vagrant 创建虚拟环境


    1. 添加box

    vagrant box add --name centos6.8/cms boxname.box

    2.初始化admin环境

    vagrant init centos6.8/cms admin

    3.启动环境

    vagrant up

    vagrantfile配置文件设置

    # -*- mode: ruby -*-
    # vi: set ft=ruby :
    
    Vagrant.configure("2") do |config|
      #BOX名称
      config.vm.box = "centos6.8/cms"
    
      #端口转发
      config.vm.network "forwarded_port", guest: 80, host: 80
      config.vm.network "forwarded_port", guest: 22, host: 2222
      config.vm.network "forwarded_port", guest: 3306, host: 3306
      config.vm.network "forwarded_port", guest: 6790, host: 6790
      config.vm.network "forwarded_port", guest: 6454, host: 6454
    
      #vagrant中虚拟环境名称
      config.vm.box_url = "admin"
    
      #vagrant中指定虚拟环境配置
      config.vm.define :admin do |ad|
        #目录共享 主机目录,虚拟机目录
        # ad.vm.synced_folder "www", "/data/www"
        #禁用vagrant的默认共享目录
        ad.vm.synced_folder ".", "/vagrant", disabled:false 
         
        #虚拟机配置
        ad.vm.provider "virtualbox" do |vb|
          #指定vm-name,也就是virtualbox管理控制台中的虚机名称
          vb.name = "cms_all_centos6.8"
          # vagrant up启动时,是否自动打开virtual box的窗口,缺省为false
          vb.gui = false
          #指定vm内存,单位为MB
          vb.memory = "1024"
          #设置CPU个数
          vb.cpus = 2
        end
      end
    
      #SSH验证
      config.ssh.username = "vagrant"
      config.ssh.private_key_path = "./id_rsa"
    
    end
     
    ...
    ...
     
     
    ...
    ...
     
     
    ...
    ...
     
  • 相关阅读:
    使用PHP类库PHPqrCode生成二维码
    40+个对初学者非常有用的PHP技巧
    (高级篇)jQuery学习之jQuery Ajax用法详解
    lerna管理前端模块实践
    Node.js:深入浅出 http 与 stream
    从koa-session源码解读session本质
    Elastichsearch实践
    Linux代理搭建TinyProxy
    linux常用命令
    node前后端同构的踩坑经历
  • 原文地址:https://www.cnblogs.com/GNblog/p/8427511.html
Copyright © 2020-2023  润新知