docker基于LAMP架构搭建wordpress

#拉取镜像包
[root@C8_48 ~]# docker pull centos 

#创建容器并后台运行 [root@C8_48
~]# docker run -d -it --privileged=true -p 80:80 -p 3306:3306 centos /sbin/init
#进入容器,先修改yum源 [root@e8b9b62046cf
~]# yum -y install wget [root@e8b9b62046cf ~]# rm -rf /etc/yum.repos.d/* [root@e8b9b62046cf ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo [root@e8b9b62046cf ~]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm [root@e8b9b62046cf ~]# sed -i 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel* [root@e8b9b62046cf ~]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
#安装lamp相关包 [root@e8b9b62046cf ~]# dnf -y install httpd php php-json php-mysqlnd mariadb-server unzip
#修改apaceh配置文件 [root@e8b9b62046cf ~]# vim /etc/httpd/conf/httpd.conf <IfModule dir_module> DirectoryIndex index.php index.html </IfModule>
#启动数据和httpd [root@e8b9b62046cf ~]# systemctl enable --now httpd mariadb
#创建wordpress数据库 [root@e8b9b62046cf ~]# mysql MariaDB [(none)]> create database wordpress; MariaDB [(none)]> grant all on wordpress.* to wordpress@'localhost' identified by '123456';
#将wordpress包从宿主机拷贝进容器 [root@C8_48 ~]# docker cp /wordpress-5.4.2-zh_CN.zip e8b9b62046cf:/opt
#解压包 [root@e8b9b62046cf ~]# cd /opt [root@e8b9b62046cf ~]# unzip wordpress-5.4.2-zh_CN.zip
#将wordpress包拷贝到httpd主页目录下 [root@e8b9b62046cf ~]# cp /opt/wordpress/* /var/www/html/
#修改httpd主页目录权限 [root@e8b9b62046cf ~]# chown -R apache.apache /var/www/html/ #浏览器登录服务地址进行配置
原文地址:https://www.cnblogs.com/nj-duzi/p/13977862.html