在Windows系统上使用VirtualBox的Vagrant和Docker来搭建WordPress网站
环境
- Windows 10.0.14393
准备
-
- VirtualBox-5.0.28-111378-Win.exe 可拓展至全局包-5.0.28-111378-Win.exe
- vagrant_1.8.6.msi 可計劃化_1.8.6.msi
放置文件
C:\users\%USERNAME%\vagrant
└─wordpress
│ Vagrantfile
│
└─provision
wordpress.sh
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.provider "virtualbox" do |vb|
vb.memory = 1024
end
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.network :forwarded_port, host: 8080, guest: 8080
config.vm.provision :shell, :path => "./provision/wordpress.sh", :privileged => true
# config.vm.network "private_network", ip: "192.168.0.100"
end
#!/bin/sh
yum -y update
yum -y install docker
systemctl start docker
docker pull wordpress
docker pull mysql
docker run --name wp-mysql -e MYSQL_ROOT_PASSWORD=password -d mysql
docker run --name wordpress --link wp-mysql:mysql -p 8080:80 -d wordpress
虚拟机启动
cd C:\users\%USERNAME%\vagrant\wordpress
vagrant up
アクセスしてみる
- http://localhost:8080
以上