Bedrock + Sage (Blade) WordPress Local Development Environment on Windows with Docker & Docker Compose
Install docker https://docs.docker.com/get-docker/ Install WSL https://learn.microsoft.com/de-de/windows/wsl/install | https://learn.microsoft.com/de-de/windows/wsl/about
Setting up WSL:
- start Ubuntu bash / sh (or whatever linux dispo you've picked)
- sudo apt-get install
- install php8
- install composer
- install nodeJs
- install php-zip
- install 7z-zip
Setting up the local Docker Env:
-
Create your project folder (for example:
ykk-template
) -
Download the files or clone the repo to your project folder
-
Replace the 'env-files/.env.localdev' database variables and the 'WP_HOME'
-
Replace the 'server-conf/nginx/nginx.conf' server_name with the same name you used on WP_HOME (without 'http://')
-
Replace all the containers' names, and database variables in the docker-compose.yml file
-
Use your terminal to
cd
into your project folder and run the commanddocker-compose --project-name your-project-name up -d --build
-
Open the Docker Desktop UI to check all 4 containers are mounted and running
-
On docker desktop open the php container cli via
docker exec -it $id sh
(or bash if WSL system differs from ubuntu) and run: 'composer create-project roots/bedrock' to create the Bedrock WordPress. Wait until the installation finishes. -
Edit your computer hosts file to add your new project server name so it will map to your application. The hosts file is a simple text file that contains any hostnames or domain names used in your local system. At the bottom of this file you should add the following lines:
127.0.0.1 ykk-template.local 127.0.0.1 www.ykk-template.local
You will find it under 'C:\Windows\System32\drivers\etc' on Windows (open as administrator). './etc/hosts' on mac & linux.
-
Now you can use any browser to access your application using http://ykk-template.local/. As the hostname is set up in your system and hosted in your system (inside a docker container) it is not published on the internet. Only your machine/system will be able to access this url.
-
To access the website go to: http://ykk-template.local
-
To access the WordPress admin got to: http://ykk-template.local/wp/wp-admin
-
To access the PHPMyAdmin go to: http://ykk-template.local:8080
The docker-compose.yml file will mount 4 containers/services:
- DB (database)
- PHP (PHP 8.1)
- NGinx (server)
- PHPMyAdmin (for managing the database)