本文需要Docker环境,相关安装教程很多,这里不再赘述
1. 安装wordpress
使用docker search命令搜索镜像
docker search wordpress
[root@MiWiFi-RC01-srv ~] INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED docker.io docker.io/wordpress The WordPress rich content management syst... 5260 [OK] docker.io docker.io/bitnami/wordpress Bitnami container image for WordPress 224 [OK] docker.io docker.io/bitnami/wordpress-nginx Bitnami Docker Image for WordPress with NGINX 75 [OK] docker.io docker.io/rapidfort/wordpress RapidFort optimized, hardened image for Wo... 15 docker.io docker.io/appsvcorg/wordpress-alpine-php New WordPress image for AppService: https:... 14 docker.io docker.io/centurylink/wordpress WordPress image with MySQL removed. 14 [OK] docker.io docker.io/wordpressdevelop/php PHP images for the WordPress local develop... 13 docker.io docker.io/wordpressdevelop/cli WP-CLI images for the WordPress local deve... 8 docker.io docker.io/ansibleplaybookbundle/wordpress-ha-apb An APB which deploys WordPress HA 5 [OK] docker.io docker.io/wordpressdevelop/phpunit PHPUnit images for the WordPress local dev... 5 docker.io docker.io/vulhub/wordpress-4.6-rce WordPress 4.6 任意命令执行漏洞(PHPMailer) 2 [OK] docker.io docker.io/bitnami/wordpress-intel 1 docker.io docker.io/bitnami/wordpress-k8s-rds-cnab CNAB bundle for WordPress on Kubernetes co... 1 docker.io docker.io/ellakcy/wordpressswithplugins A wordpress extention of original wordpres... 1 docker.io docker.io/securecodebox/old-wordpress Insecure & Outdated WordPress Instance: Ne... 1 docker.io docker.io/wordpresscharmers/wordpress The WordPress Kubernetes Image 1 docker.io docker.io/wordpressweb/boats 1 docker.io docker.io/avenga/wordpress 0 docker.io docker.io/betterweb/wordpress Docker WordPress with Redis 0 docker.io docker.io/bitnamicharts/wordpress 0 docker.io docker.io/blackflysolutions/wordpress 0 docker.io docker.io/clearlinux/wordpress 0 docker.io docker.io/corpusops/wordpress https://github.com/corpusops/docker-images/ 0 docker.io docker.io/secoresearch/wordpress Apache+PHP+Varnish+Wordpress 0 [OK] docker.io docker.io/vulhub/wordpress 0
使用docker pull拉取镜像(这里本地已经拉取过)
docker pull wordpress
[root@MiWiFi-RC01-srv ~] Using default tag: latest Trying to pull repository docker.io/library/wordpress ... latest: Pulling from docker.io/library/wordpress Digest: sha256:20b0b2c6c8f0ebe1317a427699578e581ec59c39e46fc408891c08dafccbbfd5 Status: Image is up to date for docker.io/wordpress:latest
docker run运行wordpress
docker run -d -p 80:80 --name wordpress00 wordpress
[root@MiWiFi-RC01-srv ~] 795748985b7ba475275f2c1bd41f397e854f908022e1af378c17cff6c53f2d32
参数说明
-d 直接后台运行
-p 指定容器端口绑定到主机端口 -p 主机端口:容器端口
–name 命名容器 – -name 容器名
2.安装mysql数据库
这里直接使用docker run运行
本地没有镜像会直接到公共仓库拉取
docker run -d -p 3301:3306 -e MYSQL_ROOT_PASSWORD=12345678 --name mysql00 mysql:5.7
[root@MiWiFi-RC01-srv ~] 83d03d81ab2a1d39f3edee7e18a09973fc7567252df28319974bf24988d7b815
参数说明
-e 设置环境变量 -e MYSQL_ROOT_PASSWORD=12345678 数据库root密码12345678
创建wordpress数据库
docker exec进入容器内部
docker exec -it mysql00 /bin/bash
[root@MiWiFi-RC01-srv ~] bash-4.2
进入数据库
mysql -u root -p12345678
bash-4.2 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.42 MySQL Community Server (GPL) Copyright (c) 2000, 2023, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
语法说明
-u 用户名
-p 密码
创建数据库
CREATE DATABASE wordpress;
mysql> CREATE DATABASE wordpress; Query OK, 1 row affected (0.00 sec)
查看是否成功创建
SHOW DATABASES;
mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | wordpress | +--------------------+ 5 rows in set (0.00 sec)
exit退出数据库
exit
mysql> exit Bye
Ctrl+P+Q
退出容器
bash-4.2 [root@MiWiFi-RC01-srv ~]
3.初始化wordpress
输入主机地址进入
选择语言后继续
创建 wp-config.php 文件(也可手动编辑该文件)
链接数据库
数据库名:输入mysql创建的库名
用户名及密码:使用创建库时的密码
数据库主机:主机地址:数据库映射端口号
例:
PS:如果没有防火墙没有放行端口会报错,需要关闭防火墙或者允许防火墙通过端口,ECS主机需要额外配置安全组规则
关闭防火墙
systemctl stop firewalld.service
[root@MiWiFi-RC01-srv ~]
进入安装程序
输入信息,根据自身修改
wordpress不会验证邮箱
完成后登陆即可
原文链接:https://blog.csdn.net/weixin_43935695/article/details/131103740?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168994567316800211558691%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=168994567316800211558691&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-21-131103740-null-null.268%5Ev1%5Ekoosearch&utm_term=docker%E3%80%81wordpress%E3%80%81wordpress%E5%BB%BA%E7%AB%99%E3%80%81wordpress%E4%B8%BB%E9%A2%98%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81