English English French French Spanish Spanish German German
Geekflare is supported by our audience. We may earn affiliate commissions from buying links on this site.
Share on:

How to Setup WordPress in Docker with EasyEngine?

wp docker
Invicti Web Application Security Scanner – the only solution that delivers automatic verification of vulnerabilities with Proof-Based Scanning™.

A quick look at setting up WordPress in Docker using EasyEngine on Cloud or VPS.

Docker has excellent growth in the last few years and still growing. It is everywhere – from startup to enterprise.

docker

Docker got some of the cool advantages over traditional VM, but this post is not to talk about that. If you are interested in learning in-depth, then I would recommend taking this online course.

Back to topic…

So you know or heard the Docker benefits and keen to try using for WordPress. Technically, there are many ways to do this but let’s check out EasyEngine which make life easier.

I’ve following tested on Google Cloud, but technically, it should work on any cloud hosting like DigitalOcean, Linode, AWS, Alibaba Cloud.

My Google Cloud instance is ready.

google-cloud-instance

and, logged in as a root

google-cloud-logged-in

EasyEngine is an automated script which needs to be installed on the server where you want to create a WordPress site. So let’s get it installed with the following commands.

Note: EasyEngine doesn’t work on CentOS yet, so you got to use either Debian or Ubuntu.

wget -qO ee rt.cx/ee4 && sudo bash ee

It will take a few minutes to install the necessary components including Docker, and you should see the following information before it returns to the prompt.

Status: Downloaded newer image for easyengine/redis:v4.0.0
+-------------------+----------------------------------------------------------------------------------+
| OS                | Linux 4.15.0-1025-gcp #26~16.04.1-Ubuntu SMP Wed Nov 21 10:13:20 UTC 2018 x86_64 |
| Shell             | /bin/bash                                                                        |
| PHP binary        | /usr/bin/php7.2                                                                  |
| PHP version       | 7.2.13-1+ubuntu16.04.1+deb.sury.org+1                                            |
| php.ini used      | /etc/php/7.2/cli/php.ini                                                         |
| EE root dir       | phar://ee.phar                                                                   |
| EE vendor dir     | phar://ee.phar/vendor                                                            |
| EE phar path      | /root                                                                            |
| EE packages dir   |                                                                                  |
| EE global config  |                                                                                  |
| EE project config |                                                                                  |
| EE version        | 4.0.6                                                                            |
+-------------------+----------------------------------------------------------------------------------+
-----> Run "ee help site" for more information on how to create a site.

This means EasyEngine is installed and ready to use to create a site. It depends on the requirement, and there are multiple types of sites you can create.

Ex:

  • Just an HTML site
  • WordPress site without caching or extra features
  • Create a PHP-based site with a database
  • A site with self-sign or let’s encrypt SSL certificate
  • Multi-site WordPress sites
  • WP site on sub-domain or sub-directory
  • WP site with Redis cache

You see, there are multiple combinations possibility and you can always refer their official documentation. For now, let’s create a WP site with Redis.

ee site create geekflarelab.com --type=wp --cache

Above, I am asking EasyEngine to create a WP site for geekflarelab.com and use a cache. It will take a few seconds, and you should see a success confirmation like below.

root@geekflare-lab:~# ee site create geekflarelab.com --type=wp --cache
Configuring project.
Creating WordPress site geekflarelab.com
Copying configuration files.
Starting site's services.
Downloading and configuring WordPress.
Success: Host entry successfully added.
Checking and verifying site-up status. This may take some time.

Installing WordPress site.
Success: http://geekflarelab.com has been created successfully!
Site entry created.
Creating cron entry
Success: Cron created successfully
+--------------------+----------------------------------------+
| Site               | http://geekflarelab.com                |
+--------------------+----------------------------------------+
| Site Root          | /opt/easyengine/sites/geekflarelab.com |
+--------------------+----------------------------------------+
| Site Title         | geekflarelab.com                       |
+--------------------+----------------------------------------+
| WordPress Username | stupefied-margulis                     |
+--------------------+----------------------------------------+
| WordPress Password | xxxxxxxxxxxx                           |
+--------------------+----------------------------------------+
| DB Host            | global-db                              |
+--------------------+----------------------------------------+
| DB Name            | geekflarelab_com                       |
+--------------------+----------------------------------------+
| DB User            | geekflarelab.com-bNmEbX                |
+--------------------+----------------------------------------+
| DB Password        | xxxxxxxxxxxx                           |
+--------------------+----------------------------------------+
| E-Mail             | admin@geekflarelab.com                 |
+--------------------+----------------------------------------+
| SSL                | Not Enabled                            |
+--------------------+----------------------------------------+
| Cache              | Enabled                                |
+--------------------+----------------------------------------+
root@geekflare-lab:~#

You see how fast it is to get your site up and running on the cloud?

geekflarelab-e1544957015635

Great!

Let’s verify what caching mechanism is used.

easyengine-redis

and, as you can see, WP Redis is installed along with the site creation.

WP is running inside the docker, but you don’t have to do anything for it as everything is managed by EasyEngine scripts. Most of the time, you would be interacting with ee scripts. However, if you want to explore services running inside the docker, then you can check out the following.

Processes inside the docker

docker ps would show all the running services.

root@geekflare-lab:~# docker ps
CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS              PORTS                                      NAMES
6f16b878d548        easyengine/cron:v4.0.0          "/usr/bin/ofelia dae…"   23 minutes ago      Up 23 minutes                                                  ee-cron-scheduler
18b7d9b4b8ac        easyengine/nginx:v4.0.0         "/usr/bin/openresty …"   24 minutes ago      Up 24 minutes       80/tcp                                     geekflarelabcom_nginx_1
5e36d6998bba        easyengine/postfix:v4.0.0       "postfix start-fg"       24 minutes ago      Up 24 minutes       25/tcp                                     geekflarelabcom_postfix_1
9fba9f5a2c77        easyengine/php:v4.0.0           "docker-entrypoint.s…"   24 minutes ago      Up 24 minutes       9000/tcp                                   geekflarelabcom_php_1
d022dd6635d3        easyengine/mariadb:v4.0.0       "docker-entrypoint.s…"   24 minutes ago      Up 24 minutes       3306/tcp                                   ee-global-db
5c29ba40fa06        easyengine/redis:v4.0.0         "docker-entrypoint.s…"   24 minutes ago      Up 24 minutes       6379/tcp                                   ee-global-redis
cae69382b545        easyengine/nginx-proxy:v4.0.1   "/app/docker-entrypo…"   15 hours ago        Up 35 minutes       0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   ee-global-nginx-proxy

As you can see, Nginx, PHP, MariaDB, Redis, Nginx, etc. – all running inside the docker.

Memory, IO, CPU stats

docker stats will give you real-time utilization statistics

CONTAINER ID        NAME                        CPU %               MEM USAGE / LIMIT    MEM %               NET I/O             BLOCK I/O           PIDS
6f16b878d548        ee-cron-scheduler           0.10%               6.246MiB / 1.65GiB   0.37%               1.82kB / 0B         582kB / 0B          7
18b7d9b4b8ac        geekflarelabcom_nginx_1     0.00%               4.316MiB / 1.65GiB   0.26%               3.94MB / 3.74MB     0B / 0B             2
5e36d6998bba        geekflarelabcom_postfix_1   0.00%               4.59MiB / 1.65GiB    0.27%               2.32kB / 688B       3MB / 0B            4
9fba9f5a2c77        geekflarelabcom_php_1       0.00%               12.86MiB / 1.65GiB   0.76%               38.4MB / 7.11MB     18.3MB / 180kB      1
d022dd6635d3        ee-global-db                0.05%               97.02MiB / 1.65GiB   5.74%               1.71MB / 1.75MB     59.7MB / 98.8MB     32
5c29ba40fa06        ee-global-redis             0.12%               2.48MiB / 1.65GiB    0.15%               3.31MB / 23.1MB     7.11MB / 0B         4
cae69382b545        ee-global-nginx-proxy       0.11%               8.988MiB / 1.65GiB   0.53%               2.95MB / 3.2MB      23.2MB / 53.2kB     19

Logs location

I understand you need to review the logs for troubleshooting and time to time. You can find them here.

Nginx & PHP – /opt/easyengine/sites/$SITENAME/logs

EE is well structured, and if interested to learn more then I would recommend checking their handbook. Running WordPress inside the Docker is easy now!

If you don’t want to manage WP server, optimization, security by yourself, then you may try Kinsta who take care of everything for you so you can focus on your core business.

Thanks to our Sponsors
More great readings on Development
Power Your Business
Some of the tools and services to help your business grow.
  • Invicti uses the Proof-Based Scanning™ to automatically verify the identified vulnerabilities and generate actionable results within just hours.
    Try Invicti
  • Web scraping, residential proxy, proxy manager, web unlocker, search engine crawler, and all you need to collect web data.
    Try Brightdata
  • Semrush is an all-in-one digital marketing solution with more than 50 tools in SEO, social media, and content marketing.
    Try Semrush
  • Intruder is an online vulnerability scanner that finds cyber security weaknesses in your infrastructure, to avoid costly data breaches.
    Try Intruder