1.0.1 • Published 3 years ago

wp-4-docker v1.0.1

Weekly downloads
45
License
GPL-2.0+
Repository
github
Last release
3 years ago

WP 4 Docker

This is a Docker based local environment for WordPress developing using the new WSL2.

Table of Content

  1. Overview
  2. Requirements
  3. Getting Started
  4. MySQL
  5. MailHog

Overview

WP 4 Docker is an easy and automate local development environment for WordPress that works on Linux, macOS, and Windows 10 Home ( Version 2004 ) for WSL2.

Requirements

Getting Started

Before you begin, I would like to point out one of the file that gets used often, and that file is custom.yml and when you docker up for the first time, it will then duplicate default.yml to custom.yml inside of the global folder and it will use that to generate any sites you want. By default, the only site that gets create is the dashboard and sandbox. You can manually copy the default.yml and copy to the .global folder and rename to custom.yml and start your process of creating your sites. up.

Supressing prompts for elevating privileges

To allow vagrant to automatically update the hosts file without asking for a sudo password, add one of the following snippets to a new sudoers file include, i.e. sudo visudo -f /etc/sudoers.d/vagrant_hostsupdater.

For Ubuntu and most Linux environments:

Allow passwordless startup of Vagrant with vagrant-hostsupdater.

The most easiest way to achieve powerless sudo is to add your user to the sudoers with no password and it works with Linux and macOS

Windows: UAC Prompt

You can use cacls or icacls to grant your user account permanent write permission to the system's hosts file. You have to open an elevated command prompt; hold ❖ Win and press X, then choose "Command Prompt (Admin)"

How to Begin

To begin, use git to clone the repository to anywhere

I would like to keep this simple so I'm going to clone the repository to a folder called WordPress and navigate to the folder

At this point, since all the volumes has been set already in the docker-compose.yml file, you don't need to do anything from here so to get started, please use the following command

Before you begin, you should always wait for between 5 to 10 seconds everytime when you either start, restart, or up due to mysql container needs to finished initializing or else the the included provision will fail. After you have waited, let's begin,

This will provision setup, databases, dashboard, sites, resources, each will do their parts. After it finishes, make sure to restart the containers, but in reality, you should only need to restart the nginx container, all you need to do is wp4docker restart nginx, if you just do a wp4docker restart nginx, it will restart all three containers.

Please note for the sake of containers, you should not do wp4docker up or wp4docker down often, you should only use these if you need to change to a different container or something fail or screws up the containers. Mostly you should only use wp4docker start, wp4docker restart, or wp4docker stop as much as possible.

When you add new sites if necessary, just follow copy and paste one of the sites and modify it. Then you should do a wp4docker provision and wp4docker restart nginx.

Certificates and phpMyAdmin

In the custom.yml file, there is a section where you will see phpMyAdmin and TLS-CA, this is where any resources will go so that it will generated any resources that comes with. At this time, only phpMyAdmin and TLS-CA is included since the project itself will be using https rather than http for connection.

As for the certificates, it will generate a root ca and the rest for sites. You should only need to install the ca.crt and it should be SSL ready.

MySQL

By default, only the root is set, but the good thing is that when creating a WordPress site, it will then create a new user and password "wordpress" and it will then create a database if exists and will launched.

When you create a new site, it will use wordpress by default, you can use both root or wordpress to login.

MailHog

You can now access MailHog

WordPress

ClassicPress

ClassicPress is now supported, to aactivate, use the following