docker_practice/compose/wordpress.md
Kang HuaiShuai 709c77adcb
Update title style
Signed-off-by: Kang HuaiShuai <khs1994@khs1994.com>
2019-11-05 23:35:43 +08:00

52 lines
1.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 使用 WordPress
> 本小节内容适合 `PHP` 开发人员阅读
`Compose` 可以很便捷的让 `Wordpress` 运行在一个独立的环境中
## 创建空文件夹
假设新建一个名为 `wordpress` 的文件夹然后进入这个文件夹
## 创建 `docker-compose.yml` 文件
[`docker-compose.yml`](https://github.com/yeasy/docker_practice/blob/master/compose/demo/wordpress/docker-compose.yml) 文件将开启一个 `wordpress` 服务和一个独立的 `MySQL` 实例:
```yaml
version: "3"
services:
db:
image: mysql:8.0
command:
- --default_authentication_plugin=mysql_native_password
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data:
```
## 构建并运行项目
运行 `docker-compose up -d` Compose 就会拉取镜像再创建我们所需要的镜像然后启动 `wordpress` 和数据库容器 接着浏览器访问 `127.0.0.1:8000` 端口就能看到 `WordPress` 安装界面了