Categories
Hard Skills Software Development

My WordPress Development Environment on M1 Mac / Apple Silicon (using docker)

How to set up a WordPress development environment on Apple Silicon, using Docker, that is easy to set up and maintain? Read more …

If you are here because you are still looking for a good, simple, and free way to set up a WordPress development environment, especially if you are on Apple Silicon, you are reading the right article.

Depending on your machine, there are plenty of free and almost free applications to host a PHP development environment. Unfortunately, most of them are either have a horrible interface or not well supported on Apple Silicon. The other choice is to set up each piece of PHP installation, MySQL, and a server like Apache, separately.

When I was looking for a simple way to set up WordPress for development, I was looking for something that is working, costs no money, is ad-free, and is easy to set up, also to maintain. After I found nothing that I would have liked, I started looking for Docker as a solution. Fortunately, I quickly found that WordPress has a Docker image; also, I found plenty of articles on how to set it up properly. The best of them for me at the time was a Yoast article that provided me the template for a docker-compose file, which I can use now for my development purposes.

Before you run the single command to set up everything, there is one software you need to install. That is the Docker Desktop application.

Here is the Docker Compose File created for WordPress installation using MySQL and the latest PHP, Apache, and WordPress.

# /wordpress-docker/docker-compose.yml
---
version: '3.3'
services:
  db:
    container_name: 'local-wordpress-db'
    image: 'mysql:8.0'
    volumes:
      - './data/mysql:/var/lib/mysql'
    ports:
      - 18766:3306
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress_db
      MYSQL_USER: wordpress_user
      MYSQL_PASSWORD: wordpress_password
  wordpress:
    container_name: 'local-wordpress'
    depends_on:
      - db
    image: 'wordpress:latest'
    ports:
      - 80:80
    environment:
      WORDPRESS_DB_HOST: 'db:3306'
      WORDPRESS_DB_USER: wordpress_user
      WORDPRESS_DB_PASSWORD: wordpress_password
      WORDPRESS_DB_NAME: wordpress_db
    volumes:
      - "./wordpress:/var/www/html"
      - "./plugins:/var/www/html/wp-content/plugins"

Installation in terminal: docker-compose up -d

IDE of choice: PHPStorm (Paid)

Free IDE alternative: VS Code.

By Botond Bertalan

I love programming and architecting code that solves real business problems and gives value for the end-user.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.