Installation Runbook: Ghost, A blogging Website

Dependencies

Installation Runbook: Ghost, A blogging Website

Dependencies

  1. You have a server/VM/node
  2. For your server, all networking ports should be open at the firewall/security group level

Runbook Steps

  1. SSH into your VM
  2. Install Docker and Docker Compose
# Update your system 
 
sudo apt update && sudo apt upgrade -y 
sudo apt install -y \ 
  ca-certificates \ 
  curl \ 
  gnupg \ 
  lsb-release
# Add Docker’s official GPG key 
 
sudo mkdir -p /etc/apt/keyrings 
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \ 
  sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# Set up the Docker repository 
 
echo \ 
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \ 
  https://download.docker.com/linux/ubuntu \ 
  $(lsb_release -cs) stable" | \ 
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker Engine 
 
sudo apt update 
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Start and enable Docker 
 
sudo systemctl enable docker 
sudo systemctl start docker
# (Optional) Run Docker as a non-root user 
sudo usermod -aG docker $USER 
newgrp docker

3. Set up the docker-compose.yml file
In your VM, create a docker-compose.yml file

version: '3.1' 
 
services: 
  ghost: 
    image: ghost:latest 
    depends_on: 
      - db 
    restart: always 
    ports: 
      - 80:2368 
    environment: 
      # see https://ghost.org/docs/config/#configuration-options 
      database__client: mysql 
      database__connection__host: db 
      database__connection__user: ghost 
      database__connection__password: iamahardpassword 
      database__connection__database: ghost 
      # this url value is just an example, and is likely wrong for your environment! 
      url: http://server-ip-ordomain:80 
      # contrary to the default mentioned in the linked documentation, this image defaults to NODE_ENV=production (so development mode needs to be explicitly specified if desired) 
      #NODE_ENV: development 
    volumes: 
      - ghost:/var/lib/ghost/content 
 
  db: 
    image: mysql:8.0 
    restart: always 
    environment: 
      MYSQL_ROOT_PASSWORD: iamahardpassword 
      MYSQL_DATABASE: ghost 
      MYSQL_USER: ghost 
      MYSQL_PASSWORD: iamahardpassword 
    volumes: 
      - db:/var/lib/mysql 
 
volumes: 
  ghost: 
  db:

You will have to modify the url flag in the YAML file
Any other flags and variable modifications are optional

4. Run Docker Compose

docker compose -f ./docker-compose.yml up -d

5. Enable Firewall and enable ports

sudo apt update 
sudo apt install ufw 
sudo ufw allow ssh  
sudo ufw allow 8080 
sudo ufw enable

5. Access your website on

http://$SERVER_IP

access Ghost Settings on

http://$SERVER_IP/ghost

Shivam Anand