使用docker-compose一键部署wordpress与nextcloud

维护了4(5?)年的老博客因为忘记续费丢掉了 o(╥﹏╥)o 只好直接搭个现成的了

本博客基于nextcloud的docker-compose,基本上可以一键部署,感觉还是蛮方便的.

步骤:

首先装好docker和docker-compose,注意如果是ubuntu,apt-get的compose版本可能比较老,最好手动装一下

  1. git clone https://github.com/nextcloud/docker.git
  2. cd docker/.examples/docker-compose/with-nginx-proxy/mariadb/apache/
  3. vim db.env #自己修改下密码.跟下面的docker-compose.yml文件的密码对应即可
  4. vim docker-compose.yml #具体修改参考后文
  5. docker-compose build –pull (pull是两个- 排版被删除了一个)
  6. docker-compse up -d
  7. 现在就可以通过blog.mikoto.me与mikoto.me访问啦

以下是具体的docker-compose.yml( 其实可以把两个数据库整合在一起 ,但这样也挺好用的):

version: '3'

services:
  db:
    image: mariadb 
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=你的密码
    env_file:
      - db.env
  
  wordpress:
    depends_on:
      - wordpress_db
    image: wordpress:latest
    volumes:
      - wordpress_files:/var/www/html
    
    restart: always
    environment:
      - WORDPRESS_DB_HOST=wordpress_db:3306
      - WORDPRESS_DB_USER=wordpress
      - WORDPRESS_DB_PASSWORD=你的密码
      - VIRTUAL_HOST=blog.mikoto.me
      - LETSENCRYPT_HOST=blog.mikoto.me
      - LETSENCRYPT_EMAIL=jwbin830@gmail.com
    networks:
      - proxy-tier
      - default
  wordpress_db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=你的密码
      - MYSQL_DATABASE=wordpress
      - MYSQL_USER=wordpress
      - MYSQL_PASSWORD=你的密码
    
  app:
    image: nextcloud:apache
    restart: always
    volumes:
      - nextcloud:/var/www/html
    environment:
      - VIRTUAL_HOST=mikoto.me
      - LETSENCRYPT_HOST=mikoto.me
      - LETSENCRYPT_EMAIL=jwbin830@gmail.com
      - MYSQL_HOST=db
    env_file:
      - db.env
    depends_on:
      - db
    networks:
      - proxy-tier
      - default

  proxy:
    build: ./proxy
    restart: always
    ports:
      - 80:80
      - 443:443
    labels:
      com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
    volumes:
      - certs:/etc/nginx/certs:ro
      - vhost.d:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - /var/run/docker.sock:/tmp/docker.sock:ro
    networks:
      - proxy-tier

  letsencrypt-companion:
    image: jrcs/letsencrypt-nginx-proxy-companion
    restart: always
    volumes:
      - certs:/etc/nginx/certs
      - vhost.d:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
      - proxy-tier
    depends_on:
      - proxy

volumes:
  db:
  nextcloud:
  certs:
  vhost.d:
  html:
  wordpress_files:
  db_data:
networks:
  proxy-tier:

			

发表评论

电子邮件地址不会被公开。 必填项已用*标注