使用docker-compose一键部署开源博客wordpress
前言
使用 docker-compose 一键启动开源博客 wordpress
前台启动:docker-compose up
后台启动:docker-compose up -d
官方文档:https://docs.docker.com/samples/wordpress/
一键部署
第一步 创建项目文件夹并进入目录
mkdir wordpress && cd wordpress
第二步 创建 docker-compose.yml
# 注意你的docker版本是否兼容这个版本
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:
- "8090:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data:
第三步 启动
docker-compose up
docker-compose up -d (后台启动)
停止:docker-compose down
反向代理Nginx
upstream wordpress {
server 127.0.0.1:8090;
}
server {
listen 80;
listen 443 ssl;
server_name www.lidangqi.com;
ssl_certificate /opt/cert/CERTIFICATE.PEM;
ssl_certificate_key /opt/cert/PRIVATEKEY.KEY;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
client_max_body_size 250M;
location / {
proxy_pass http://wordpress;
proxy_set_header HOST host;
proxy_set_header X-Forwarded-Protoscheme;
proxy_set_header X-Real-IP remote_addr;
proxy_set_header X-Forwarded-Forproxy_add_x_forwarded_for;
}
}