Coder Social home page Coder Social logo

wordpress-nginx-docker-compose's Introduction

Docker Compose and WordPress

Build Status

Use WordPress locally with Docker using Docker compose

  • Dockerfile for extending a base image and install wp-cli
  • Local domain ex myapp.local
  • Custom nginx config in ./nginx
  • Custom PHP php.ini config in ./config
  • Volumes for nginx, wordpress and mariadb
  • WordPress using Bedrock - modern development tools, easier configuration, and an improved folder structure
  • CLI scripts
    • Create a self signed SSL certificate for using https
    • Trust certs in macOS System Keychain
    • Setup the local domain in your in /etc/hosts

Setup

Requirements

  • Docker
  • Openssl for creatng the SSL cert. Install using Homebrew brew install openssl

Create SSL cert

cd cli
./create-cert.sh

Edit the script to your your custom domain, this example uses myapp.local

Note: OpenSSL needs to be installed.

Trust the cert in macOS Keychain

Chrome and Safari will trust the certs using this script.

In Firefox: Select Advanced, Select the Encryption tab, Click View Certificates. Navigate to where you stored the certificate and click Open, Click Import.

cd cli
./trust-cert.sh

Edit the script to your your custom domain, this example uses myapp.local

Setup vhost in /etc/hosts

cd cli
./setup-hosts-file.sh

Follow the instructions. For example use myapp.local

Setup ENV

cd src
cp .env.example .env

Use the following database settings:

DB_HOST=mysql:3306
DB_NAME=myapp
DB_USER=root
DB_PASSWORD=password

Install WordPress and Composer dependencies

cd src
composer install

You can also use composer like this: docker-compose run composer update

Run

docker-compose up -d

๐Ÿš€ Open up https://myapp.local

Notes:

When making changes to the Dockerfile, use:

docker-compose up -d --force-recreate --build

Tools

wp-cli

docker exec -it myapp-wordpress bash
wp search-replace https://olddomain.com https://newdomain.com --allow-root

You can use this command first after you've installed WordPress using Composer as the example above.

Changelog

2019-08-02


Useful Docker Commands

Login to the docker container

docker exec -it myapp-wordpress bash

Stop

docker-compose stop

Down (stop and remove)

docker-compose down

Cleanup

docker-compose rm -v

Recreate

docker-compose up -d --force-recreate

Rebuild docker container when Dockerfile has changed

docker-compose up -d --force-recreate --build

wordpress-nginx-docker-compose's People

Contributors

dirkgroenen avatar urre avatar watchmydc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.