Docker-Compose

Deploy WordPress, MySQL, and a web server using Docker-Compose for a streamlined, efficient, and portable website hosting solution.

Using Docker-Compose, you can quickly deploy WordPress, MySQL, and a web server. To orchestrate containers, use a single configuration file, which simplifies setup, ensures compatibility, and enables seamless scaling of the complete web application stack.

docker-compose file is present at /root/blog-zus-network/docker-compose.yml location in the server.

This docker-compose file will launch WordPress, MySQL and Webserver.

version: '3'

services:
  db:
    image: mysql:8.0
    container_name: db
    restart: unless-stopped
    env_file: .env
    environment:
      - MYSQL_DATABASE=zchainblog
    volumes: 
      - ./dbdata:/var/lib/mysql
    command: '--default-authentication-plugin=mysql_native_password'
    networks:
      - zchain-network

  wordpress:
    depends_on: 
      - db
    image: wordpress:5.1.1-fpm-alpine
    container_name: wordpress
    restart: unless-stopped
    env_file: .env
    environment:
      - WORDPRESS_DB_HOST=db:3306
      - WORDPRESS_DB_USER=$MYSQL_USER
      - WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD
      - WORDPRESS_DB_NAME=zchainblog
    volumes:
      - ./wordpress-data:/var/www/html
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
    networks:
      - zchain-network

  webserver:
    depends_on:
      - wordpress
    image: nginx:1.15.12-alpine
    container_name: webserver
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./wordpress-data:/var/www/html
      - ./nginx-conf:/etc/nginx/conf.d
      - ./certbot-etc:/etc/letsencrypt
      - /etc/letsencrypt/live/blog.zus.network/fullchain.pem:/etc/letsencrypt/live/blog.zus.network/fullchain.pem
      - /etc/letsencrypt/live/blog.zus.network/privkey.pem:/etc/letsencrypt/live/blog.zus.network/privkey.pem
    networks:
      - zchain-network

volumes:
  wordpress:
  dbdata:

networks:
  zchain-network:
    driver: bridge  

This nginx configuration file is present at /root/blog-zus-network/nginx-conf/nginx.conf location on the server.

This file present at location /root/blog-zus-network/nginx-conf/options-ssl-nginx.conf

Run following command to launch WordPress, MySQL and webserver from directory -

Last updated