docker compose for nginx php-fpm and wordpress

Posted on Tue 06 December 2016 in 折腾

lnmp假如是个人使用的话,当然是版本越高越好。

docker 部署应用非常方便,比什么一键包方便多了。docker 官方 wordpress 的镜像是 自带有 apache 的,但是习惯了 nginx了,发现官方还有 wordpress:fpm 的tag,就用 docker-compose 再跑一个 nginx 加上 wordpress:fpm。

虽然docker hub 上也有其他个人开发者做的docker,但是还是官方维护的靠谱一点,而且官方的 image 更新还快一点。

git clone git@github.com:jianggau/Dockerfile.git

cd mywordpress1

docker-compose up -d

环境就好了。

然后下面是 docker-compose.yml  (github):

version: '2'

services:

  db:

  image: mysql:5.7

  volumes:

  - ./db_data:/var/lib/mysql

  restart: always

  environment:

  MYSQL_ROOT_PASSWORD: wordpress

  MYSQL_DATABASE: wordpress

  MYSQL_USER: wordpress

  MYSQL_PASSWORD: wordpress

  web:

  image: nginx

  volumes:

  - /root/my_wordpress1/nginx/conf.d:/etc/nginx/conf.d

  - /root/my_wordpress1/nginx/global:/etc/nginx/global

  - /etc/letsencrypt:/etc/letsencrypt

  - /root/my_wordpress1/nginx/log:/var/log/nginx

  # - /root/my_wordpress1/nginx/html:/var/www/html

  # - /root/my_wordpress1/wordpress:/var/www/wordpress

  volumes_from:

  - wordpress

  restart: always

  depends_on:

  - db

  - wordpress

  ports:

  - "80:80"

  - "443:443"

  wordpress:

  depends_on:

  - db

  image: wordpress:fpm

  #volumes:

  # - /root/my_wordpress1/wordpress:/var/www/wordpress

  restart: always

  environment:

  WORDPRESS_DB_HOST: db:3306

  WORDPRESS_DB_PASSWORD: wordpress