deploy :
安装 docker
yum install docker
systemctl start docker
systemctl enable docker
安装docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
版本
docker-compose -v
docker-compose version 1.23.2, build 1110ad01
新建目录 ,
存放web-sql和Wordpress数据 (文件夹名称推荐按照站点域名一致)
mkdir -p /wordpress/
生成docker-compose 文件
vi docker-compose.yml
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- /wordpress/db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress-root
MYSQL_DATABASE: wordpress-db
MYSQL_USER: wordpress-user
MYSQL_PASSWORD: wordpress-user-ps
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- /wordpress/wordpress_data:/var/www/html
ports:
- "80:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress-user
WORDPRESS_DB_PASSWORD: wordpress-user-ps
WORDPRESS_DB_NAME: wordpress-db
使用nginx代理
如果使用nginx做代理访问wordpress,修改docker 端口映射信息,将80端口让出即可:
ports:
- "8080:80"
启动服务:
cd /wordpress/
docker-compose up -d
查看容器状态
docker-compose ps
or
docker ps
## 初始化站点
由于wordpress初始化过程会根据访问站点地址初始化数库信息,推荐首次初始化站点使用正式域名访问,没有进行dns解析的,可以先写host文件。