- Created from [wordpress-nginx-docker](https://github.com/mjstealey/wordpress-nginx-docker)
- SSL Certificates are created with [SSL For Free](https://www.sslforfree.com/?domains=biuro.lt%20www.biuro.lt%20dev.biuro.lt%20staging.biuro.lt%20biuro.lv%20www.biuro.lv%20dev.biuro.lv%20staging.biuro.lv%20biuro.ee%20www.biuro.ee%20dev.biuro.ee%20staging.biuro.ee)
Let's Encrypt SSL enabled option using [https://hub.docker.com/r/certbot/certbot/](https://hub.docker.com/r/certbot/certbot/)
## Workflow
- Install [Docker Desktop](https://www.docker.com/products/docker-desktop) on your machine
- Creating new User on my machine helped me with sharing C drive problem (https://tomssl.com/2018/01/11/sharing-your-c-drive-with-docker-for-windows-when-using-azure-active-directory-azuread-aad/)
Work inspired by: [Dockerizing Wordpress with Nginx and PHP-FPM on Ubuntu 16.04](https://www.howtoforge.com/tutorial/dockerizing-wordpress-with-nginx-and-php-fpm/)
### Wordpress
- Regions created using [Wordpress Network](https://codex.wordpress.org/Create_A_Network)
## Installation
#### Plugins
Review the [Optional configuration](#opt_config) options and determine if you'd like to apply any.
### Create directories on host
Directories are created on the host to persist data for the containers to volume mount from the host.
-**mysql**: The database files for MariaDB
-**wordpress**: The WordPress media files
-**logs/nginx**: The Nginx log files (error.log, access.log)
-**certs**: SSL certificate files (LetsEncrypt)
-**certs-data**: SSL challenge/response area (LetsEncrypt)
From the top level of the cloned repository, create the directories that will be used for managing the data on the host.
If you plan to run your WordPress site over http on port 80, then do the following.
1. Change the name of `nginx/wordpress.conf.example` to `nginx/wordpress.conf`
2. Update the `DOMAIN_NAME` in `nginx/wordpress.conf` to be that of your domain
3. Run `$ docker-compose up -d`
4. Navigate to [http://DOMAIN_NAME]() in a browser where `DOMAIN_NAME` is the name of your site
### HTTPS with SSL Certificates
If you plan to run your WordPress site over https on port 443, then do the following.
**Choose a method for SSL certificates**
-**Let's Encrypt**
If you plan on using SSL certificates from [Let's Encrypt](https://letsencrypt.org) it is important that your public domain is already registered and reachable.
Run: `./letsencrypt/letsencrypt-init.sh DOMAIN_NAME`, where `DOMAIN_NAME` is the publicly registered domain name of your host.
```
$ ./letsencrypt-init.sh example.com
mysql uses an image, skipping
wordpress uses an image, skipping
nginx uses an image, skipping
Creating mysql ...
Creating mysql ... done
Creating wordpress ...
Creating wordpress ... done
Creating nginx ...
Creating nginx ... done
Reloading nginx: nginx.
Saving debug log to /var/log/letsencrypt/letsencrypt.log
If you plan on using self signed SSL certificates, run: `./letsencrypt/self-signed-init.sh DOMAIN_NAME`, where `DOMAIN_NAME` is the `CN` you want to assign to the host (commonly `localhost`).
- 48: #ssl_trusted_certificate /etc/letsencrypt/live/DOMAIN_NAME/chain.pem; <-- COMMENT OUT OR REMOVE
```
-**Bring your own**
If you plan to use pre-existing certificates you will need to update the `nginx/wordpress_ssl.conf` file with the appropriate settings to the kind of certificates you have.
**Finally**
1. Change the name of `nginx/wordpress_ssl.conf.example` to `nginx/wordpress_ssl.conf`
2. Update the `DOMAIN_NAME` in `nginx/wordpress_ssl.conf` to be that of your domain
3. Run `$ docker-compose up -d`
4. Navigate to [https://DOMAIN_NAME]() in a browser where `DOMAIN_NAME` is the name of your site
WordPress environment variables. See the [official image](https://hub.docker.com/_/wordpress/) for additional information.
-`WORDPRESS_DB_NAME`: Name of database used for WordPress in MariaDB
-`WORDPRESS_TABLE_PREFIX`: Prefix appended to all WordPress related tables in the `WORDPRESS_DB_NAME` database
-`WORDPRESS_DB_HOST `: Hostname of the database server / container
-`WORDPRESS_DB_PASSWORD `: Database password for the `WORDPRESS_DB_USER`. By default 'root' is the `WORDPRESS_DB_USER`.
```yaml
environment:
-WORDPRESS_DB_NAME=wordpress
-WORDPRESS_TABLE_PREFIX=wp_
-WORDPRESS_DB_HOST=mysql
-WORDPRESS_DB_PASSWORD=password
```
MySQL environment variables.
- If you've altered the `WORDPRESS_DB_PASSWORD` you should also set the `MYSQL_ROOT_PASSWORD ` to be the same as they will both be associated with the user 'root'.
```yaml
environment:
-MYSQL_ROOT_PASSWORD=password
```
### Port Mapping
Neither the **mysql** container nor the **wordpress** container have publicly exposed ports. They are running on the host using a docker defined network named `wp_network` which provides the containers with access to each others ports, but not from the host.
If you wish to expose the ports to the host, you'd need to alter the stanzas for each in the `docker-compose.yaml` file.
Docker compose installation of a single site Wordpress instance using Nginx as the web server and MariaDB as the database.
Let's Encrypt SSL enabled option using [https://hub.docker.com/r/certbot/certbot/](https://hub.docker.com/r/certbot/certbot/)
Work inspired by: [Dockerizing Wordpress with Nginx and PHP-FPM on Ubuntu 16.04](https://www.howtoforge.com/tutorial/dockerizing-wordpress-with-nginx-and-php-fpm/)
## Installation
Review the [Optional configuration](#opt_config) options and determine if you'd like to apply any.
### Create directories on host
Directories are created on the host to persist data for the containers to volume mount from the host.
- **mysql**: The database files for MariaDB
- **wordpress**: The WordPress media files
- **logs/nginx**: The Nginx log files (error.log, access.log)
- **certs**: SSL certificate files (LetsEncrypt)
- **certs-data**: SSL challenge/response area (LetsEncrypt)
From the top level of the cloned repository, create the directories that will be used for managing the data on the host.
If you plan to run your WordPress site over http on port 80, then do the following.
1. Change the name of `nginx/wordpress.conf.example` to `nginx/wordpress.conf`
2. Update the `DOMAIN_NAME` in `nginx/wordpress.conf` to be that of your domain
3. Run `$ docker-compose up -d`
4. Navigate to [http://DOMAIN_NAME]() in a browser where `DOMAIN_NAME` is the name of your site
### HTTPS with SSL Certificates
If you plan to run your WordPress site over https on port 443, then do the following.
**Choose a method for SSL certificates**
- **Let's Encrypt**
If you plan on using SSL certificates from [Let's Encrypt](https://letsencrypt.org) it is important that your public domain is already registered and reachable.
Run: `./letsencrypt/letsencrypt-init.sh DOMAIN_NAME`, where `DOMAIN_NAME` is the publicly registered domain name of your host.
```
$ ./letsencrypt-init.sh example.com
mysql uses an image, skipping
wordpress uses an image, skipping
nginx uses an image, skipping
Creating mysql ...
Creating mysql ... done
Creating wordpress ...
Creating wordpress ... done
Creating nginx ...
Creating nginx ... done
Reloading nginx: nginx.
Saving debug log to /var/log/letsencrypt/letsencrypt.log
If you plan on using self signed SSL certificates, run: `./letsencrypt/self-signed-init.sh DOMAIN_NAME`, where `DOMAIN_NAME` is the `CN` you want to assign to the host (commonly `localhost`).
- 48: #ssl_trusted_certificate /etc/letsencrypt/live/DOMAIN_NAME/chain.pem; <-- COMMENT OUT OR REMOVE
```
- **Bring your own**
If you plan to use pre-existing certificates you will need to update the `nginx/wordpress_ssl.conf` file with the appropriate settings to the kind of certificates you have.
**Finally**
1. Change the name of `nginx/wordpress_ssl.conf.example` to `nginx/wordpress_ssl.conf`
2. Update the `DOMAIN_NAME` in `nginx/wordpress_ssl.conf` to be that of your domain
3. Run `$ docker-compose up -d`
4. Navigate to [https://DOMAIN_NAME]() in a browser where `DOMAIN_NAME` is the name of your site
WordPress environment variables. See the [official image](https://hub.docker.com/_/wordpress/) for additional information.
- `WORDPRESS_DB_NAME`: Name of database used for WordPress in MariaDB
- `WORDPRESS_TABLE_PREFIX`: Prefix appended to all WordPress related tables in the `WORDPRESS_DB_NAME` database
- `WORDPRESS_DB_HOST `: Hostname of the database server / container
- `WORDPRESS_DB_PASSWORD `: Database password for the `WORDPRESS_DB_USER`. By default 'root' is the `WORDPRESS_DB_USER`.
```yaml
environment:
- WORDPRESS_DB_NAME=wordpress
- WORDPRESS_TABLE_PREFIX=wp_
- WORDPRESS_DB_HOST=mysql
- WORDPRESS_DB_PASSWORD=password
```
MySQL environment variables.
- If you've altered the `WORDPRESS_DB_PASSWORD` you should also set the `MYSQL_ROOT_PASSWORD ` to be the same as they will both be associated with the user 'root'.
```yaml
environment:
- MYSQL_ROOT_PASSWORD=password
```
### Port Mapping
Neither the **mysql** container nor the **wordpress** container have publicly exposed ports. They are running on the host using a docker defined network named `wp_network` which provides the containers with access to each others ports, but not from the host.
If you wish to expose the ports to the host, you'd need to alter the stanzas for each in the `docker-compose.yaml` file.