https://www.youtube.com/watch?v=kIqWxjDj4IU
- Install docker desktop application in your computer.
- Install brew. This is for installing mkcert. You can also use Curl to install mkcert.
- Install mkcert globally:
brew install mkcert
andbrew install nss
. The first command installs mkcert. The second command installs a certutil to allow Firefox to trust the CA. - Run
mkcert -install
. This will create the local certificate authority.
- Clone this repo to your local computer. Rename the folder to your project name.
- Download the latest WordPress and copy the wordpress folder to the root folder. So the root folder has folders: /nginx/ and /wordpress/.
- Create a new folder in /nginx/ called /certs/. cd into /nginx/certs/, and run
mkcert yoursitename.dev
, this will create SSL certificates of the domain. - Change database name, username, password in docker-compose.yml to your preferred values.
- Change the domain names in /nginx/default.conf from sitename.dev to yoursitename.dev.
- Stop other containers in Docker Desktop that use the same port, cd into the root folder and run
docker-compose up -d --build
. This will build the container and start the container. After this, you should see a new directory /mysql/ in the root folder. - Add the domain to the host file by running
sudo code /etc/hosts
(for VSCODE), then add127.0.0.1 yoursitename.dev
to the host file and save. - Visit https://yoursitename.dev and go through the installation process. The Database Host should be the server name: 'mysql', not 'localhost'.
- Now the site should be up and running with SSL.
- Connect to the database (tested with Sequal Ace): Values should match docker-compose.yml. The docker container should be up and running when trying to connect to the database.
- Host: 127.0.0.1
- Username: yourusername
- Password: yourpassword
- Database: yourdatabasename
- Port: 3306
- When building containers with custom configurations, you can't use images directly in the yaml file. Instead, you need to use docker files for the configurations. Eg. nginx.dockerfile, php.dockerfile. When building containers with dockerfiles, you need to run
docker-compose build
instead ofdocker-compose up
. You can also just rundocker-compose up -d --build
to build and start the container at the same time. - The /mysql/ directory is for storing the mysql volume, so when you stop the container, you won't lose any data.
- in docker-compose.yml
platform: linux/x86_64
is used to avoid error "no matching manifest for linux/arm64/v8 in the manifest list entries" when building the container. This happens when you are using a Mac with M1 chip. - Your database root password can not be "root". Otherwise you will get error Access denied for user 'root'@'172.27.0.1’ when trying to connect the database.