用Docker搭建WordPress博客

[TOC]html

前言

本文基於Centos 7 環境的docker搭建操做,centos 7 用 firewalld 替換了iptables做爲默認防火牆操做,但之前習慣了iptables 就不與時俱進了。mysql

環境準備

systemctl disable firewalld
systemctl stop firewalld
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
yum install iptables iptables-services net-tools vim
systemctl enable iptables
systemctl start iptables

iptables -A INPUT -p tcp --dport 80 -j ACCEPT

iptables-save > /etc/sysconfig/iptables
systemctl restart iptables.service
yum -y install epel-release

Docker 安裝

yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-compose
systemctl enable docker 
systemctl start docker 
docker pull wordpress
docker pull mysql:5.7

### 運行mysql
mkdir -p /opt/data/apps/wordpress/data
chown -R 999:999 /opt/data/apps/wordpress/data

docker run --name mysql -h mysql --restart=always -e MYSQL_ROOT_PASSWORD=12345678 \
-v /opt/data/apps/wordpress/data:/var/lib/mysql \
-v /opt/data/temp:/opt/soft \
-d mysql:5.7

### 運行wordpress 
mkdir -p /opt/data/apps/wordpress/webapps
chown -R 33:33 /opt/data/apps/wordpress/webapps

docker run -h wordpress --name wordpress  --restart=always --link mysql:mysql -p 80:80 \
-v /opt/data/apps/wordpress/webapps:/var/www/html \
-v /opt/data/temp:/opt/soft \
-d wordpress
相關文章
相關標籤/搜索