參考文檔:2019 年 最簡單最通俗的 vagrant 安裝使用說明,附帶示例Vagrantfile
參考文檔:2019年最新最快最簡潔最詳細的docker 和 docker-compose 安裝使用說明html
vagrant + virtualbox
virtualbox
【官網下載】python
【VirtualBox 6.0.8 platform packages 下載】mysql
安裝說明: 下一步下一步,選擇下安裝目錄就行git
vagrant
【官網下載】github
安裝說明: 下一步下一步,選擇下安裝目錄就行redis
vagrant + virtualbox
mkdir lincms
請加QQ羣:1020151684,sql
備註:我想體驗lincms全家桶docker
而後獲取全家桶源碼shell
vagrant init
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.require_version ">= 1.6.0" boxes = [ { :name => "lincms", :eth1 => "10.10.1.10", :mem => "1024", :cpu => "1" } ] Vagrant.configure(2) do |config| config.vm.box = "ubuntu/bionic" boxes.each do |opts| config.vm.define opts[:name] do |config| config.vm.hostname = opts[:name] config.vm.provider "vmware_fusion" do |v| v.vmx["memsize"] = opts[:mem] v.vmx["numvcpus"] = opts[:cpu] end config.vm.provider "virtualbox" do |v| v.customize ["modifyvm", :id, "--memory", opts[:mem]] v.customize ["modifyvm", :id, "--cpus", opts[:cpu]] end config.vm.network :private_network, ip: opts[:eth1] end end config.vm.synced_folder "./lincms", "/home/vagrant/lincms" config.vm.provision "shell", privileged: true, path: "./setup.sh" end
setup.sh
文件# Timezone sudo /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo 'Asia/Shanghai' > /etc/timezone # 設置國內源 sudo mv /etc/apt/sources.list /etc/apt/sources.list.back && \ echo '# 默認註釋了源碼鏡像以提升 apt update 速度,若有須要可自行取消註釋 \n \ deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse \n \ deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse \n \ deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse \n \ deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse \n \ deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse \n \ deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse \n \ deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse \n \ deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse \n \ deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse \n \ deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse' >> /etc/apt/sources.list # Libs sudo apt-get update && sudo apt-get install -y wget curl git vim gcc glibc-static telnet bridge-utils # install docker sudo curl -fsSL https://get.docker.com | sudo bash -s docker --mirror Aliyun sudo groupadd docker sudo gpasswd -a vagrant docker sudo systemctl start docker rm -rf get-docker.sh # 配置鏡像加速器 sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://dt77flbr.mirror.aliyuncs.com"] } EOF sudo systemctl enable docker sudo systemctl daemon-reload sudo systemctl restart docker # #下載docker-compose # sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose # #給docker-compose執行權限 # sudo chmod +x /usr/local/bin/docker-compose # #測試安裝是否成功,成功的話打印出docker-compose的版本信息 # sudo docker-compose --version # 使用pip安裝docker-compose sudo apt install python-pip -y sudo pip install docker-compose # 打印IP地址信息 ip a # 進入項目目錄 cd lincms # 建立/啓動項目 sudo docker-compose build && sudo docker-compose up -d
10.10.1.10:9000
curl 10.10.1.10:9000
若是能看到 TP5.1歡迎頁面,就證實部署成功了數據庫
10.10.1.10:9001
默認建立數據庫:lincms
MySQL root 密碼:123456
MySQL 帳戶1: lincms
MySQL 密碼: 123456
10.10.1.10:9002