用Docker搭建WordPress博客
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用Docker搭建WordPress博客相关的知识,希望对你有一定的参考价值。
[TOC]
前言
本文基于Centos 7 环境的docker搭建操作,centos 7 用 firewalld 替换了iptables作为默认防火墙操作,但以前习惯了iptables 就不与时俱进了。
环境准备
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 -A INPUT -p tcp --dport 8443 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.203.0/24 -o eth0 -j MASQUERADE
iptables -A FORWARD -s 192.168.203.0/24 -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=1qaz2wsx -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
以上是关于用Docker搭建WordPress博客的主要内容,如果未能解决你的问题,请参考以下文章