CentOS下Docker-compose部署WordPress
WordPress介绍
WordPress是使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设属于自己的网站。也可以把 WordPress当作一个内容管理系统(CMS)来使用。
WordPress是一款个人博客系统,并逐步演化成一款内容管理系统软件,它是使用PHP语言和MySQL数据库开发的,用户可以在支持 PHP 和 MySQL数据库的服务器上使用自己的博客。
WordPress有许多第三方开发的免费模板,安装方式简单易用。不过要做一个自己的模板,则需要你有一定的专业知识。比如你至少要懂的标准通用标记语言下的一个应用HTML代码、CSS、PHP等相关知识。
WordPress官方支持中文版,同时有爱好者开发的第三方中文语言包,如wopus中文语言包。WordPress拥有成千上万个各式插件和不计其数的主题模板样式。
WordPress安装部署
环境:CentOS 7.9、Docker、
1、创建项目目录
[root@docker Dockerfile]# mkdir wordpress
[root@docker Dockerfile]# cd wordpress/
2、创建一个docker-compose.yml
启动 WordPress
博客的文件和一个带有MySQL
卷装载的单独实例以实现数据持久性
[root@docker wordpress]# vim docker_compose.yml
services:
db:
# We use a mariadb image which supports both amd64 & arm64 architecture
image: mariadb:10.6.4-focal
# If you really want to use MySQL, uncomment the following line
#image: mysql:8.0.27
command: '--default-authentication-plugin=mysql_native_password'
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=somewordpress
- MYSQL_DATABASE=wordpress
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=wordpress
expose:
- 3306
- 33060
wordpress:
image: wordpress:latest
volumes:
- wp_data:/var/www/html
ports:
- 80:80
restart: always
environment:
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=wordpress
- WORDPRESS_DB_NAME=wordpress
volumes:
db_data:
wp_data:
3、构建项目
[root@docker wordpress]# docker compose up -d
[+] Running 29/12
⠿ db Pulled 31.4s
⠙ wordpress Pulling 150.0s
canceled
[root@docker wordpress]# docker compose up -d
[+] Running 22/22
⠿ wordpress Pulled 45.6s
⠿ 3f9582a2cbe7 Already exists 0.0s
⠿ 0b95dc92ce55 Pull complete 3.4s
⠿ 3630ff9f8131 Pull complete 21.2s
⠿ 49efbc577363 Pull complete 21.2s
⠿ df983cae2963 Pull complete 21.9s
⠿ 52fed2cf4dcf Pull complete 21.9s
⠿ badf42672f1b Pull complete 22.0s
⠿ baaffcad7804 Pull complete 39.1s
⠿ e65c63290641 Pull complete 39.2s
⠿ 56fbc7142e6c Pull complete 39.6s
⠿ 0b0f64aca9a8 Pull complete 39.7s
⠿ 1a0de30c1e15 Pull complete 39.8s
⠿ c28dd6954d0b Pull complete 39.8s
⠿ 12b130c64439 Pull complete 40.5s
⠿ b7956b05af90 Pull complete 41.0s
⠿ bce2c530d546 Pull complete 41.1s
⠿ 275d52fd4f6c Pull complete 41.2s
⠿ 841c64b802b3 Pull complete 41.2s
⠿ af298c263b20 Pull complete 42.5s
⠿ 6d98f1e7e80e Pull complete 42.5s
⠿ e77d1e0ab8c5 Pull complete 42.6s
[+] Running 5/5
⠿ Network wordpress_default Created 0.2s
⠿ Volume "wordpress_wp_data" Created 0.0s
⠿ Volume "wordpress_db_data" Created 0.0s
⠿ Container wordpress-wordpress-1 Started 1.6s
⠿ Container wordpress-db-1 Started 1.5s
[root@docker wordpress]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ea47fee45f39 wordpress:latest "docker-entrypoint.s…" 7 seconds ago Up 5 seconds 0.0.0.0:80->80/tcp, :::80->80/tcp wordpress-wordpress-1
10621dbfa79f mariadb:10.6.4-focal "docker-entrypoint.s…" 7 seconds ago Up 5 seconds 3306/tcp, 33060/tcp wordpress-db-1
4、浏览器访问192.168.152.139
注:密码最好改一下,后面需要登录使用
至此,恭喜成功部署了你自己的博客网站