DEV Community

Cover image for How to install WordPress locally on Mac simply with Docker Compose file 🤘
Stan Kukučka
Stan Kukučka

Posted on • Edited on

How to install WordPress locally on Mac simply with Docker Compose file 🤘

Common Practice

There is a common practice on how to setup WordPress development locally. Mostly used are XAMPP and WAMP for this purpose or similar. How to install Wordpress without these?

Quickest and Fastest Way

Today I would like you to show for me the easiest and fastest way how to make WordPress work for you on your local machine in almost a few simple steps. We gonna use Docker hub and it will take 10 minutes.

Download and Install

Alt Text

Download Mac stable installation on official Docker hub domain here:

👉 Download Docker Desktop

Run installation from the dmg file you have downloaded.

Alt Text

Approve access and privileged access that Docker Desktop will ask for.

Copying WordPress Docker Image File

Create a directory for the website for example on Desktop, so go to Desktop, create directory wpwebsite and enter into it using these commands one by one.



cd Desktop
mkdir wpwebsite
cd wpwebsite


Enter fullscreen mode Exit fullscreen mode

Save this docker-compose.yml you will find hereunder file into wpwebsite directory. It's an image for WordPress docker container installation that will set up all needed, like WordPress directory structure and MariaDB database as well.

👉 docker-compose.yml

Running WordPress Docker Container

Now type into terminal this simple command.



docker-compose up


Enter fullscreen mode Exit fullscreen mode

Login Into WordPress And Install

You are ready to go through WordPress installation on your local machine. Go into the browser and type this URL.



http://localhost:2000


Enter fullscreen mode Exit fullscreen mode

Alt Text

Docker Desktop Dashboard

Pass all this installation and now you are ready to login to your local WordPress installation. You can check it as well on Docker Desktop Dashboard clicking on a tiny icon on your top panel.

Alt Text

And check it anytime how DB and website are running and stop or delete it anytime.

Alt Text

Login Into Wordpress CMS

When you want to access your local WordPress installation next time just type wp-login.php after localhost:2000, so whole url to start installation will be like this.



http://localhost:2000/wp-login.php


Enter fullscreen mode Exit fullscreen mode

And yeah, don't forget to copy some theme into wpwebsite/wp-content/themes to see something real in your browser, cos this standard installation doesn't have any.

Enjoy Local WordPress Development

Hope you enjoyed this little WordPress installation adventure and found it interesting and now you are ready to go with a local WordPress theme or plugin development.

If you have questions or enjoyed this article, please feel free to comment or message me here or share if you think others might be interested too.

Thanks to Isaac Ibbott for the cover image from Unsplash.

Top comments (2)

Collapse
 
ajs profile image
Anvar J S

thanks but after following the steps getting this error Error establishing a database connection? Any ideas

Collapse
 
stankukucka profile image
Stan Kukučka • Edited

hi @ajs sorry for the late reply. It worked in my environment quite well. Maybe try this compose file

version: '3'
services:
db:
image: mariadb:latest
volumes:
- /tmp/dc-test-db:/var/lib/mysql
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: admin
restart: always
wordpress:
image: wordpress:latest
volumes:
- /tmp/dc-test-wordpress:/var/www/html
ports:
- "8082:80"
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_PASSWORD: admin
restart: on-failure
Enter fullscreen mode Exit fullscreen mode