DEV Community

Cover image for Self Hosting WordPress
Lim Guan Ji
Lim Guan Ji

Posted on • Updated on

Self Hosting WordPress

My latest obsession has been self-hosting ever since getting my Raspberry PI, I've began exploring docker compose files and setting them up.

One of the useful resources that I look for to do self-hosting is from
https://hub.docker.com/

One of the amazing things about docker is the folder structure, here I can specify my own directory, making docker generate the files at the mention directories.

Note that this docker compose is for raspberry pi setup, however it should also work for x86 systems as well.

version: '3.1'

services:

  wordpress:
    container_name: wordpress
    image: wordpress
    restart: always
    ports:
      - 9005:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - wordpress:/var/www/html

  db:
    image: mysql/mysql-server:latest
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - db/var/lib/mysql

volumes:
  wordpress: /opt/containers/wordpress/html #Define your own path
  db: /opt/containers/wordpress/mysql #Define your own path
Enter fullscreen mode Exit fullscreen mode

Top comments (0)