Commit a2a5f1d3 authored by Simonas's avatar Simonas

README init

parent 08d77b3a
# wordpress-nginx-docker
# Biuro websites
Docker compose installation of a single site Wordpress instance using Nginx as the web server and MariaDB as the database.
## Information
- Project repository [dev.biuro](http://git.biuro.lt/biuro/dev.biuro)
- 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/)
- Clone [dev.biuro](http://git.biuro.lt/biuro/dev.biuro) repository
- in Windows PowerShell run `docker-compose up -d`
- `docker ps` command should output existing docker containers (nginx, mysql, wordpress)
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.
```
$ cd wordpress-nginx-docker/
# mkdir -p certs/ certs-data/ logs/nginx/ mysql/ wordpress/
```
### HTTP
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
Plugins selected: Authenticator webroot, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): mjstealey@gmail.com
-------------------------------------------------------------------------------
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf. You must agree
in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: a
-------------------------------------------------------------------------------
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about EFF and
our work to encrypt the web, protect its users and defend digital rights.
-------------------------------------------------------------------------------
(Y)es/(N)o: y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
http-01 challenge for www.example.com
Using the webroot path /data/letsencrypt for all unmatched domains.
Waiting for verification...
Cleaning up challenges
IMPORTANT NOTES:
ssl on;
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/example.com/privkey.pem
Your cert will expire on 2018-02-06. To obtain a new or tweaked
version of this certificate in the future, simply run certbot
again. To non-interactively renew *all* of your certificates, run
"certbot renew"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
Stopping nginx ... done
Stopping wordpress ... done
Stopping mysql ... done
Going to remove nginx, wordpress, mysql
Removing nginx ... done
Removing wordpress ... done
Removing mysql ... done
INFO: update the nginx/wordpress_ssl.conf file
- 4: server_name example.com;
- 19: server_name example.com www.example.com;
- 46: ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
- 47: ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
- 48: ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
```
- **Self signed**
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`).
```
$ cd letsencrypt/
$ ./self-signed-init.sh localhost
INFO: making certs directory
Generating a 4096 bit RSA private key
................................................................................................................................................................................................................................................++
....................................................++
writing new private key to 'key.pem'
-----
INFO: update the nginx/wordpress_ssl.conf file
- 4: server_name localhost;
- 19: server_name localhost www.localhost;
- 46: ssl_certificate /etc/letsencrypt/live/localhost/cert.pem;
- 47: ssl_certificate_key /etc/letsencrypt/live/localhost/privkey.pem;
- 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
## <a name="opt_config"></a>Optional Configuration
### Environment Varialbles
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.
For the `mysql` stanza, add
```
ports:
- '3306:3306'
```
For the `wordpress` stanza, add
```
ports:
- '9000:9000'
```
## Clean up / Removal
Removing all related containers
```
$ cd wordpress-nginx-docker/
$ docker-compose stop
$ docker-compose rm -f
```
Removing all related directories
```
$ cd wordpress-nginx-docker/
$ rm -rf certs/ certs-data/ logs/ mysql/ wordpress/
```
# wordpress-nginx-docker
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.
```
$ cd wordpress-nginx-docker/
# mkdir -p certs/ certs-data/ logs/nginx/ mysql/ wordpress/
```
### HTTP
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
Plugins selected: Authenticator webroot, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): mjstealey@gmail.com
-------------------------------------------------------------------------------
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf. You must agree
in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: a
-------------------------------------------------------------------------------
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about EFF and
our work to encrypt the web, protect its users and defend digital rights.
-------------------------------------------------------------------------------
(Y)es/(N)o: y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
http-01 challenge for www.example.com
Using the webroot path /data/letsencrypt for all unmatched domains.
Waiting for verification...
Cleaning up challenges
IMPORTANT NOTES:
ssl on;
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/example.com/privkey.pem
Your cert will expire on 2018-02-06. To obtain a new or tweaked
version of this certificate in the future, simply run certbot
again. To non-interactively renew *all* of your certificates, run
"certbot renew"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
Stopping nginx ... done
Stopping wordpress ... done
Stopping mysql ... done
Going to remove nginx, wordpress, mysql
Removing nginx ... done
Removing wordpress ... done
Removing mysql ... done
INFO: update the nginx/wordpress_ssl.conf file
- 4: server_name example.com;
- 19: server_name example.com www.example.com;
- 46: ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
- 47: ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
- 48: ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
```
- **Self signed**
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`).
```
$ cd letsencrypt/
$ ./self-signed-init.sh localhost
INFO: making certs directory
Generating a 4096 bit RSA private key
................................................................................................................................................................................................................................................++
....................................................++
writing new private key to 'key.pem'
-----
INFO: update the nginx/wordpress_ssl.conf file
- 4: server_name localhost;
- 19: server_name localhost www.localhost;
- 46: ssl_certificate /etc/letsencrypt/live/localhost/cert.pem;
- 47: ssl_certificate_key /etc/letsencrypt/live/localhost/privkey.pem;
- 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
## <a name="opt_config"></a>Optional Configuration
### Environment Varialbles
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.
For the `mysql` stanza, add
```
ports:
- '3306:3306'
```
For the `wordpress` stanza, add
```
ports:
- '9000:9000'
```
## Clean up / Removal
Removing all related containers
```
$ cd wordpress-nginx-docker/
$ docker-compose stop
$ docker-compose rm -f
```
Removing all related directories
```
$ cd wordpress-nginx-docker/
$ rm -rf certs/ certs-data/ logs/ mysql/ wordpress/
```
14,14
14,13
14,12
14,11
14,10
14,9
14,8
14,7
14,5
14,4
14,2
13,4
13,3
13,2
13,1
13,0
12,8
12,7
12,6
12,5
12,4
12,3
12,2
12,1
12,0
11,5
11,4
11,3
11,2
11,1
11,0
10,4
10,3
10,2
10,1
10,0
9,5
9,4
9,3
9,2
9,1
9,0
8,5
8,4
8,3
8,2
8,1
8,0
7,5
7,4
7,3
7,2
7,1
7,0
6,5
6,4
6,3
6,2
6,1
6,0
5,6
5,5
5,4
5,3
5,2
5,1
5,0
4,3
4,2
4,1
4,0
3,6
3,5
3,4
3,3
3,2
3,1
3,0
2,8
2,7
2,6
......@@ -54,59 +84,29 @@
2,3
2,2
2,1
2,0
1,3
1,2
1,1
0,439
1,0
0,408
0,376
0,322
0,243
40,1
40,3
14,1
40,0
14,6
14,3
14,0
30,1
30,3
0,439
30,0
0,9
0,310
0,305
5,0
6,0
8,0
7,0
9,0
10,0
21,0
20,0
22,0
19,0
16,0
15,0
14,0
13,0
12,0
11,0
17,0
18,0
34,0
33,0
35,0
36,0
42,0
41,0
40,0
39,0
38,0
37,0
24,0
23,0
25,0
26,0
32,0
31,0
30,0
29,0
28,0
27,0
3,0
1,0
2,0
4,0
0,308
0,304
0,303
......@@ -171,122 +171,122 @@
0,275
0,406
0,274
12,5
12,6
12,8
13,1
13,3
13,4
14,2
14,4
14,5
14,7
14,8
14,10
14,12
14,13
14,15
14,16
14,18
14,19
14,21
14,23
14,22
14,24
14,26
14,27
14,29
14,31
14,30
14,32
15,1
15,2
15,3
15,4
15,5
16,1
16,3
16,5
16,2
16,4
16,6
16,7
17,1
17,2
17,4
18,0
18,1
18,2
18,3
18,4
19,1
19,3
19,2
19,4
20,1
20,2
20,4
21,1
21,3
21,0
21,2
21,4
21,6
21,5
21,7
21,8
22,1
22,3
22,2
22,4
22,6
22,7
23,1
23,2
23,4
23,5
24,2
24,0
24,1
24,3
24,5
24,4
25,0
25,2
25,3
25,5
26,1
26,0
26,2
26,3
27,1
27,0
27,2
27,4
27,3
27,5
28,0
28,2
28,3
28,4
28,5
28,7
28,8
29,1
29,2
29,3
30,1
30,3
29,4
30,4
30,5
31,1
31,2
31,4
31,5
32,2
32,0
32,1
32,3
32,4
32,5
32,6
32,7
33,1
33,3
33,5
33,4
34,0
34,1
34,3
34,4
35,1
34,5
35,0
35,2
35,3
35,4
35,5
36,1
36,2
36,4
37,1
37,0
37,2
37,3
37,5
38,1
38,3
38,2
38,4
38,6
38,8
38,5
38,7
39,0
39,1
39,3
39,4
40,2
40,3
40,4
40,5
41,2
41,1
41,3
41,5
41,4
42,0
42,1
42,3
42,5
......@@ -294,73 +294,73 @@
42,7
42,4
42,2
41,4
41,1
40,4
40,1
41,5
41,2
41,0
40,2
39,2
38,7
38,5
38,2
38,8
38,6
38,3
38,0
37,4
37,2
37,1
36,3
35,5
35,2
34,5
36,0
35,4
35,1
34,4
34,2
33,4
33,5
33,2
32,6
32,3
32,1
33,0
32,5
32,2
31,5
31,3
30,5
31,0
30,2
29,4
29,1
29,3
29,0
28,6
28,4
28,3
28,1
27,3
27,4
27,1
26,4
26,2
26,1
25,4
25,1
24,4
24,1
24,5
24,2
23,5
23,3
22,7
23,0
22,5
22,2
21,7
21,5
21,2
22,3
22,0
21,6
21,3
21,1
20,3
20,1
19,2
18,3
20,0
19,3
19,0
18,2
17,5
17,3
16,7
16,4
16,2
15,4
15,1
14,30
17,0
16,5
16,3
16,0
15,3
15,0
14,31
14,28
14,25
14,22
14,23
14,20
14,17
14,14
14,11
14,9
14,6
14,3
14,1
13,2
12,7
0,405
0,273
0,404
......
No preview for this file type
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment