All Projects → urre → Wordpress Nginx Docker Compose

urre / Wordpress Nginx Docker Compose

Run WordPress with nginx using Docker Compose.

Projects that are alternatives of or similar to Wordpress Nginx Docker Compose

Docker Wordpress
WordPress container with Nginx 1.16 & PHP-FPM 7.3 based on Alpine Linux
Stars: ✭ 148 (-67.83%)
Mutual labels:  wp-cli, wordpress, docker-compose, nginx
Docker Nginx Php Mysql
Docker running Nginx, PHP-FPM, MySQL & PHPMyAdmin
Stars: ✭ 1,322 (+187.39%)
Mutual labels:  phpmyadmin, docker-compose, nginx
Kickoff Docker Php
🐳 🐘 🚀 Easily setup a PHP project with Docker
Stars: ✭ 213 (-53.7%)
Mutual labels:  phpmyadmin, docker-compose, nginx
Wordpressify
🎈 A build system designed to automate your WordPress development workflow.
Stars: ✭ 1,374 (+198.7%)
Mutual labels:  wordpress, docker-compose, nginx
Docker Nginx Gunicorn Flask Letsencrypt
Boilerplate code for setting up Nginx + Gunicorn + Flask + automated LetsEncrypt certificates (https) using docker-compose.
Stars: ✭ 117 (-74.57%)
Mutual labels:  https, docker-compose, nginx
Pilothouse
A command line app for managing a LEMP local development environment based on Docker.
Stars: ✭ 98 (-78.7%)
Mutual labels:  wp-cli, wordpress, nginx
Wordpress Nginx Docker
Wordpress (php7.3-fpm) using Nginx and MariaDB - deployed with docker-compose - Let's Encrypt enabled
Stars: ✭ 498 (+8.26%)
Mutual labels:  wordpress, docker-compose, nginx
Nginxconfig.io
⚙️ NGINX config generator on steroids 💉
Stars: ✭ 14,983 (+3157.17%)
Mutual labels:  wordpress, https, nginx
Wp Vps Build Guide
A verbose build guide for a modern, high-performance WordPress production VPS.
Stars: ✭ 31 (-93.26%)
Mutual labels:  wp-cli, wordpress, nginx
Wordpress Starter
📦 A starter template for WordPress websites
Stars: ✭ 26 (-94.35%)
Mutual labels:  wp-cli, wordpress, docker-compose
Wordup Cli
Wordup is a fully integrated development platform for WordPress. Develop plugins and themes locally. Preview in the cloud. Automatic updates in WP.
Stars: ✭ 116 (-74.78%)
Mutual labels:  wp-cli, wordpress, docker-compose
Docker Compose Wordpress
An example Docker Compose setup for WordPress plugin or theme development.
Stars: ✭ 127 (-72.39%)
Mutual labels:  wp-cli, wordpress, docker-compose
Webinoly
Optimized LEMP Web Server to manage your WordPress, PHP, or simple HTML sites running on a powerful NGINX setup.
Stars: ✭ 254 (-44.78%)
Mutual labels:  wordpress, nginx
exo
A process manager & log viewer for dev
Stars: ✭ 296 (-35.65%)
Mutual labels:  docker-compose, compose
Docker Lamp
Docker with Apache, MySql, PhpMyAdmin and Php
Stars: ✭ 276 (-40%)
Mutual labels:  phpmyadmin, docker-compose
Slickstack
SlickStack is a free LEMP stack automation script written in Bash designed to enhance and simplify WordPress provisioning, performance, and security.
Stars: ✭ 311 (-32.39%)
Mutual labels:  wordpress, nginx
docker-compose-v3
No description or website provided.
Stars: ✭ 15 (-96.74%)
Mutual labels:  docker-compose, compose
Express Graphql Mongodb Boilerplate
A boilerplate for Node.js apps / GraphQL-API / Authentication from scratch - express, graphql - (graphql compose), mongodb (mongoose).
Stars: ✭ 288 (-37.39%)
Mutual labels:  docker-compose, compose
Wuxt
Nuxt/WordPress development environment, combining the worlds biggest CMS with the most awesome front-end application framework yet.
Stars: ✭ 459 (-0.22%)
Mutual labels:  wordpress, docker-compose
Wordpress Nginx
WordPress specific Nginx configuration templates and best practices!
Stars: ✭ 332 (-27.83%)
Mutual labels:  wordpress, nginx

Docker Compose and WordPress

Build Status

Donate

Use WordPress locally with Docker using Docker compose

Contents

  • A Dockerfile for extending a base image and using a custom Docker image with an automated build on Docker Hub
  • PHP 7.4
  • Custom domain for example myapp.local
  • Custom nginx config in ./nginx
  • Custom PHP php.ini config in ./config
  • Volumes for nginx, wordpress and mariadb
  • Bedrock - modern development tools, easier configuration, and an improved secured folder structure for WordPress
  • Composer
  • WP-CLI - WP-CLI is the command-line interface for WordPress.
  • MailHog - An email testing tool for developers. Configure your outgoing SMTP server and view your outgoing email in a web UI.
  • PhpMyAdmin - free and open source administration tool for MySQL and MariaDB
    • PhpMyAdmin config in ./config
  • CLI script to create a SSL certificate

Instructions

Requirements

Install mkcert:

brew install mkcert
brew install nss # if you use Firefox
Setup

Setup Environment variables

Both step 1. and 2. below are required:

1. For Docker and the CLI script (Required step)

Copy .env.example in the project root to .env and edit your preferences.

Example:

IP=127.0.0.1
APP_NAME=myapp
DOMAIN="myapp.local"
DB_HOST=mysql
DB_NAME=myapp
DB_ROOT_PASSWORD=password
DB_TABLE_PREFIX=wp_

2. For WordPress (Required step)

Edit ./src/.env.example to your needs. During the composer create-project command described below, an ./src/.env will be created.

Example:

DB_NAME='myapp'
DB_USER='root'
DB_PASSWORD='password'

# Optionally, you can use a data source name (DSN)
# When using a DSN, you can remove the DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST variables
# DATABASE_URL='mysql://database_user:[email protected]_host:database_port/database_name'

# Optional variables
DB_HOST='mysql'
# DB_PREFIX='wp_'

WP_ENV='development'
WP_HOME='https://myapp.local'
WP_SITEURL="${WP_HOME}/wp"
WP_DEBUG_LOG=/path/to/debug.log

# Generate your keys here: https://roots.io/salts.html
AUTH_KEY='generateme'
SECURE_AUTH_KEY='generateme'
LOGGED_IN_KEY='generateme'
NONCE_KEY='generateme'
AUTH_SALT='generateme'
SECURE_AUTH_SALT='generateme'
LOGGED_IN_SALT='generateme'
NONCE_SALT='generateme'
Option 1). Use HTTPS with a custom domain
  1. Create a SSL cert:
cd cli
./create-cert.sh

This script will create a locally-trusted development certificates. It requires no configuration.

mkcert needs to be installed like described in Requirements. Read more for Windows and Linux

  1. Continue on the Install step below
Option 2). Use a simple config
  1. Edit nginx/default.conf.conf to use this simpler config (without using a cert and HTTPS)
server {
    listen 80;

    root /var/www/html/web;
    index index.php;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    client_max_body_size 100M;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass wordpress:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

  1. Edit the nginx service in docker-compose.yml to use port 80. 443 is not needed now.
  nginx:
    image: nginx:latest
    container_name: ${APP_NAME}-nginx
    ports:
      - '80:80'

  1. Continue on the Install step below
Install
docker-compose run composer create-project
Run
docker-compose up

Docker Compose will now start all the services for you:

Starting myapp-mysql    ... done
Starting myapp-composer ... done
Starting myapp-phpmyadmin ... done
Starting myapp-wordpress  ... done
Starting myapp-nginx      ... done
Starting myapp-mailhog    ... done

🚀 Open https://myapp.local in your browser

PhpMyAdmin

PhpMyAdmin comes installed as a service in docker-compose.

🚀 Open http://127.0.0.1:8082/ in your browser

MailHog

MailHog comes installed as a service in docker-compose.

🚀 Open http://0.0.0.0:8025/ in your browser

Tools

Update WordPress Core and Composer packages (plugins/themes)

docker-compose run composer update

Use WP-CLI

docker exec -it myapp-wordpress bash

Login to the container

wp search-replace https://olddomain.com https://newdomain.com --allow-root

Run a wp-cli command

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

Update plugins and themes from wp-admin?

You can, but I recommend to use Composer for this only. But to enable this edit ./src/config/environments/development.php (for example to use it in Dev)

Config::define('DISALLOW_FILE_EDIT', false);
Config::define('DISALLOW_FILE_MODS', false);

Useful Docker Commands

When making changes to the Dockerfile, use:

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

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
Changelog

2021-03-16

  • Changed root .env-example to .env.example to match the git ignore patterns. Thanks @scottnunemacher

2021-03-05

  • Clarify steps in the readme

2021-03-02

  • Fixed a misstake so instead of ./src/.env-example, it should be ./src/.env.example.
  • Redirect HTTP to HTTPS. Thanks @humblecoder

2021-01-02

  • Use NGINX_ENVSUBST_TEMPLATE_SUFFIX. Use a template and better substution of ENV variables in nginx config.

2020-10-04

  • Added mariadb-client (Solves #54)

2020-09-15

  • Updated Bedrock. Update WordPress to 5.5.1 and other composer updates.

2020-07-12

2020-05-03

  • Added nginx gzip compression

2020-04-19

  • Added Windows support for creating SSH cert, trusting it and setting up the host file entry. Thanks to @styssi

2020-04-12

  • Remove port number from DB_HOST. Generated database connection error in macOS Catalina. Thanks to @nirvanadev
  • Add missing ENV variable from mariadb Thanks to @vonwa

2020-03-26

2020-02-06

  • Readme improvements. Explain /etc/hosts better

2020-01-30

  • Use Entrypoint command in Docker Compose to replace the domain name in the nginx config. Removing the need to manually edit the domain name in the nginx conf. Now using the .env value DOMAIN
  • Added APP_NAME in .env-example Thanks to @Dave3o3

2020-01-11

  • Added .env support for specifying your own app name, domain etc in Docker and cli scripts.
  • Added phpMyAdmin. Visit http://127.0.0.1:8080/

2019-08-02

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].