環境:
Docker
Vagrant https://xueyuanjun.com/post/354.html
Laragon https://xueyuanjun.com/post/9609
參考文章:
[https://www.cnblogs.com/hafiz/p/9175484.html](https://www.cnblogs.com/hafiz/p/9175484.html)
[https://segmentfault.com/a/1190000000264347](https://segmentfault.com/a/1190000000264347)
https://blog.csdn.net/qq_38962739/article/details/103517520
安裝和使用
[https://blog.csdn.net/woqianduo/article/details/81091154](https://blog.csdn.net/woqianduo/article/details/81091154)
[TOC]
### 原理
vagrant介紹
vagrant是一個基于Ruby的工具,用于創建和部署虛擬化開發環境。使用Oracle的開源virtualBox虛擬化系統,使用Chef創建自動化虛擬環境。同時,vagrant也支持其他類型的虛擬機系統,如:vmware、kvm、qemu,甚至是容器系統,如docker等,當然,用的比較多的還是virtralBox。
vagrant與virtualBox原理
這里我們簡述一下vagrant與virtualBox的原理,virtualBox(本身也可以創建虛擬機,只是相對麻煩)會開放一個創建虛擬機的接口,Vagrant會利用這個接口創建虛擬機,并且通過Vagrant來管理,配置和自動安裝虛擬機。
使用Vagrant來創建虛擬機
前提,首先確保本機已經安裝好兩者。
新建一個空文件夾:mkdir centos7 ,并進入該文件夾:cd centos7/
在該目錄下初始化一個創建centos7的Vagrantfile文件,執行命令:vagrant init centos/7
創建centos7虛擬機,執行命令:vagrant up,如果本地有base box,會使用本地的,否則將會從網絡中下載,此過程可能偏久,會生成名字為如下圖所示的虛擬機:
接下來,我們將在virtualBox中看到剛剛創建的虛擬機:
注:在vagrant中box概念,是一個打包的單一文件,其中包含了一個完整系統的虛擬機相關數據。
vagrant的基本使用
執行命令:vagrant ssh ,就會通過ssh連接至剛剛我們所創建的虛擬機
如果需要退出當前連接,執行命令:exit,將會回到本地目錄
查看虛擬機狀態,在本地目錄里執行命令:vagrant status
停掉虛擬機,執行命令:vagrant halt
開啟虛擬機,執行命令:vagrant up
刪除虛擬機:vagrant destroy
查看目前已有的box:vagrant box list
新增加一個box:vagrant box add
刪除指定box:vagrant box remove
重啟虛擬機:vagrant reload
### 一、準備工作
準備以下軟件:
1.virtualbox [https://www.virtualbox.org/wiki/Downloads](https://www.virtualbox.org/wiki/Downloads)
2.vagrant [https://www.vagrantup.com/downloads.html](https://www.vagrantup.com/downloads.html)
3.git【包含gitbash】
4.已開啟vt-x【硬件虛擬化加速】
首先確認自己的CPU支持虛擬化,可以拿CPU型號去對應的廠商官網去查
重啟開機按F2或者Del進入BIOS界面。
`如果是華碩主板EZmode模式,選擇=》高級=》cpu選項,拉到最底部,選擇開啟intel虛擬化`
`如果是一般的BIOS 參見:https://blog.csdn.net/sunrise_zhu/article/details/78889793
重啟后進入startup menu,選擇Computer Setup(F10)
菜單欄中選擇Security —> System Security
Virtualization technology(VTx) 設置為enable`
5.準備好要安裝的box
官網下載鏈接:https://app.vagrantup.com/laravel/boxes/homestead/versions/8.2.1/providers/virtualbox.box
網盤下載鏈接:https://pan.baidu.com/s/1oj9g9nAORLswYSvKrhOIaA 密碼 kvf4
### 二、安裝各種軟件和插件
安裝 vagrant
安裝 vagrant的插件來支持nfs文件共享
vagrant plugin install vagrant-winnfsd
--plugin-clean-sources --plugin-source https://gems.ruby-china.com/
### 三、安裝box【這里以官方box里的centos7為例】
找一個盤,這里是F盤,創建目錄vagrantBox/{box名稱} 這里是vagrantBox/centos7,即F:\vagrantBox\centos7
在centos7目錄下,右擊gitbash,打開bash命令行界面,進行box初始化
```
$ vagrant init centos7 #執行完會生成一個vagrant啟動虛擬機的配置文件 Vagrantfile
```
然后將box導入vagrant
```
$ vagrant box add centos7 {已下載好的centos7的box文件路徑,可以放到F:\vagrantBox\centos7目錄下,則只需要填文件名}
$ vagrant box list
centos7 (virtualbox, 0)
$ vagrant up #這里會出現無法掛載共享目錄的提示,可以通過安裝 vagrant插件解決
vagrant plugin install vagrant-vbguest --plugin-clean-sources --plugin-source https://gems.ruby-china.com/
# 1.成功后再執行啟動命令 vagrant up
# 2.有可能用啟動命令進行下載會比較慢【不知為何】,可以先vagrant halt 關閉box,打開Oracle VM VirtualBox,手動雙擊打開box,
#使用默認的帳號密碼 user:root password:vagrant 進行登錄,并使用yum update 進行更新 再vagrant halt 并重新vagrant up,最終就快了很多
#這樣會下載安裝一些軟件依賴, 最終Copy iso file E:\virtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso并完成安裝和掛載
```
以下為我的啟動配置文件項
```
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "centos7"
#ssh賬戶和密碼,默認都為vagrant,注意root權限密碼也是vagrant
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
#開啟下面的配置
#網絡三種模式之一:較為常用是端口映射,就是將虛擬機中的端口映射到宿主機對應的端口直接使用
#guest: 80 表示虛擬機中的80端口, host: 8080 表示映射到宿主機的8080端口。
config.vm.network "forwarded_port", guest: 22, host: 2222, id: "ssh", disabled: "true"
config.vm.network "forwarded_port", guest: 80, host: 80
config.vm.network "forwarded_port", guest: 15672, host: 15672
config.vm.network "forwarded_port", guest: 22, host: 2221
#配置共享目錄
#原理是window共享目錄的內容,都會時時同步到虛擬機上
#"E:/phpstudy_pro/WWW":代表window路徑 ,SVN代碼checkout這里的
#"/home/www":代表linux路徑,會將window 中項目同步到這里
config.vm.synced_folder "E:/phpstudy_pro/WWW", "/home/www"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
# Customize the amount of memory on the VM:
vb.memory = "4096"
vb.cpus = 4
end
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# apt-get update
# apt-get install -y apache2
# SHELL
end
```
- 常見功能
- 第三方授權登錄
- 郵件發送
- 簡易聊天室
- 獲取各國匯率
- PHP獲取服務器硬件指標
- 數據上報之
- web開發
- 開發規范
- 前端
- 踩坑
- 將footer固定在底部
- bootstrap
- Metronic
- 用到的jquery插件
- bootstrap-hover-dropdown
- jquery.slimscroll
- jquery.blockui
- bootstrap-switch
- js.cookie
- moment
- bootstrap-daterangepicker
- morris
- raphael
- jquery.waypoints
- jquery.counterup
- select2
- 取值和設置默認值
- vue
- axios
- 瀏覽器
- 谷歌瀏覽器
- 谷歌插件
- layui
- layui-表格
- layui-表單
- layui-彈窗
- layui-分頁
- 后端
- 操作系統
- linux
- 用戶管理
- 文件管理
- 目錄管理
- 壓縮和解壓縮
- 進程查看
- 端口查看
- 開機自啟動服務
- 定時任務
- shell腳本
- 殺掉運行超過指定時長指定服務的進程
- 獲取服務器使用狀態
- bash-shell連接socket
- 自定義快捷命令
- centos-踩坑
- 防火墻
- 軟件
- yum
- vim
- screen
- window
- 語言
- PHP
- 配置優化
- 框架
- thinkphp5.1+
- think命令行
- laravel6.+
- 維護模式
- 根據環境讀取不同配置
- laravel6.+采坑
- laravel坑位
- 數據庫事務
- 任務調度
- 文件權限問題
- 增強框架
- larvel:elastic-search
- 圖形驗證碼
- laravel獲取ip
- 函數
- strtotime
- 正則匹配
- 類
- 接口類與抽象類
- 類相關的關鍵字 - abstract
- 類相關的關鍵字 - interface
- PHP有關類的調用方式"->"與"::"的區別
- 擴展
- 問題歸納
- json_encode和json_decode
- 字符串的運算
- curl
- 優化php效率
- 數組相加合并與array_merge
- 時區轉換
- 不常用特性
- php反射
- 包管理器-composer
- GuzzleHttp
- Python
- Go
- 數據庫
- Redis
- 安裝
- 本地化-數據備份
- php-redis操作
- Mysql
- mysql-命令集合
- 設置終端可訪問
- 數據庫設計
- 用戶基礎信息表
- 踩坑集合
- mysql-2002
- mysql-2054
- 優化策略
- mysql-密碼驗證插件
- 一些牛逼的sql查詢
- topN
- 無限級分類
- Memcache
- MongoDb
- 安裝mongo-server
- 安裝php-mongodb擴展
- 在laravel中使用mongoDB
- 客戶端軟件
- Hbase
- Elasticsearch
- elastic-search
- restfulApi操作es
- web服務器
- 1.nginx
- 配置語法規則
- 配置詳解
- rewrite規則
- request_filename
- 2.apache
- 功能設計
- 加密解密
- Base64
- 對亞馬遜SKU加密
- 兼職項目中的加解密
- 騰訊外包時的加密
- 接口設計
- 接口限流設計
- 分庫分表
- 遍歷展示文件目錄結構
- 時區換算
- 文件切割
- 解析xml字符串
- 項目
- 博客后臺管理
- 亞馬遜廣告API
- 官方指引文檔
- 開發人員中心
- 應用商店
- 第三方庫
- 申請API郵件記錄
- 亞馬遜MWS
- 付款報告
- 亂碼
- 亞馬遜管理庫存報告
- 報告
- 商品
- 入庫
- 履行
- 出庫
- 財務
- 訂單
- 異步任務處理
- 集群如何同步代碼
- 基本開發流程
- 文檔管理
- showdoc
- 運行環境
- 開發環境
- vagrant
- windows上配置安裝
- vagrant安裝插件緩慢
- 更換ssh默認端口映射
- 設置x-shell密碼登錄
- 使用市場的box-homestead
- homestead-7: Box 'lc/homestead'
- 常見問題
- 虛擬環境reboot
- 突然無法使用
- phpStudy
- wamp
- 壓測性能
- VPN
- vultr
- 凌空圖床
- 寶塔
- 自動化部署
- 版本管理軟件鉤子
- 線上環境-LNMP
- centos7
- nginx
- mysql
- mysql開機自啟
- mysql-更換默認端口
- datetime字段類型默認值
- php
- php擴展安裝
- redis
- swoole
- gd
- BCMath
- igbinary
- zstd
- 包管理器:composer
- 優化性能
- nodejs
- 更新gcc版本
- 版本控制
- git
- 常用命令
- gitlab
- 版本管理規范
- 使用阿里云創建遠程倉庫
- git自動化部署
- svn
- 忽略指定文件
- 拉取代碼
- 自動化運維
- jekins
- 容器
- 集群
- 架構設計
- 設計原則
- 閱讀參考
- 代碼規劃
- 架構實戰
- 服務治理
- 權限控制設計
- 具體設計
- 計劃
- 疑問知識點
- 讀書筆記
- 高性能Mysql
- TCP-IP詳解-卷一:協議
- 思考
- php如何實現并發執行
- 對接調用設計
- 如何在瀏覽器上實現插件
- 如何設計一個app結合業務告警
- mysql的where查詢沒有用到索引
- 為啥in查詢比循環嵌套sql的查詢還要慢
- 使用git來創建屬于自己的composer包
- 翻頁獲取數據的時候又新增了數據
- 安全思路
- 月報
- PHP ?? 和 ?: 的區別
- PHP異步執行
- redis集群的目標是什么
- 大文件數據處理
- 性能瓶頸分析
- 命令行里輸出帶顏色的字體
- 面試問題合集
- 基礎
- 安全
- 算法
- 冒泡排序
- 快速排序
- 二分法查詢數組指定成員
- 字符查找匹配
- 令牌桶
- 漏桶
- 計數器
- 代理
- 協議
- http
- 狀態碼
- tcp
- udp
- Oauth2.0
- 設計模式
- 單例模式
- 適配器模式
- 工廠模式
- 觀察者模式
- 流程化
- 地址欄輸入網址到返回網頁的流程
- 題目收集
- 工具
- rabbitMq
- rabbitMQ用戶管理
- 生產者
- 消費者
- 支持TP5.*的think-queue
- 消息丟失
- 消費者報錯
- rabbitMQ配置優化
- 磁盤滿載導致服務掛掉
- PHP類庫
- rabbitMQ踩坑
- navicat
- vscode
- phpstorm
- 激活碼
- markdown
- PHP自定義類庫
- 工具類
- 領導力
- 任務分配
- 代碼組織
- 不要重復
- 避免污染
- 接口定義規范
- 小業務需求
- 獲取充值面額組成
- 監控服務器CPU和內存
- shell腳本版本