One click WordPress set up with docker and docker-compose (local, live, cloud) (without SSL)

When it comes to creating websites and creating them with all the possible options available out there, “WordPress” is what comes in mind, although there are other options available as well. But it has its own place and importance in this world of web development. Moreover, there are a lot of options available to set up a website using WordPress but we are here to achieve the “One click WordPress set up“.

This can be achieved with the help of “docker” and “docker-compose“.

Note: This particular post is about “Setting up WordPress on AWS EC2 Ubuntu 18.04 instance with domain mapped to instance’s IP Address but without an SSL certificate”.

Before going further, make sure you go through the following guides:

  1. What is docker?
  2. Create an AWS instance

One more thing, we haven’t discussed the components we are going to use in this project or about the stack type. Let us learn that also:

L = Linux system is being provided by the Linux based containers.

E = This stands for Nginx (Engine X) web server

M = This stands for “MySQL” or alternatively “MariaDB

P = This stands for “PHP” and in this particular “PHP-FPM” for “Nginx

By clubbing the above components, we get what we often calls a “LEMP” Stack.

This is necessary because, without these components combined, it is impossible to achieve this “One click WordPress set up“.

Question: But there is twist to all this, what?

Answer: Everything is going to be achieved with the help of “docker containers” which help in isolating the environment from the rest of the system.

After you have read the above guides, you are good to go.

Step 1: We have created a specific GitHub repository for this, which makes it further easy to set up anywhere anytime.

As you can see from the picture below, you simply have to copy the repository’s URL, which is -> “

copy github repository url from dahboard
Copy github repository URL from dashboard

Step 2: Now, we have to log in to our AWS EC2 Ubuntu 18.04 instance, look at the picture below.

Login into aws ec2 ubuntu 18.04 instance from linux using pem private key
Login into AWS EC2 Ubuntu 18.04 instance from Linux using pem private key

Step 3: It is time to clone our repository, URL of which we have copied in the Step 1.

Note: Make sure you have git installed on your system, in particular for Debian or Ubuntu users use “sudo apt install git” and you are good to go.

After installing git, use the command used in the photo below, in order to clone a repository.

cloning a repository from github into aws ec2 ubuntu 18.04
Cloning a repository from github into AWS EC2 Ubuntu 18.04

Step 4: Check the cloned repository using the following command, and as we can see a folder/directory named as “wordpress-lemp-without-ssl” is created, which is actually the name of the repository which we have cloned.

confirm the cloned repository in current directory
Confirm the cloned repository in the current directory

Step 5: Now, we have to navigate to this folder/directory as we did and shown below.

change to the newly cloned repository in linux
Change to the newly cloned repository in Linux

Step 6: Check the contents of the directory, using the following command.

checking the cloned files and directories
Checking the cloned files and directories

Step 7: Reason behind or meaning of each and every file we have used in this project. Check the screenshot below to understand each and every file and directory.

directories and files explanation
Directories and files explanation for this project

Step 8: Now, it is time to provide a custom configuration to our “Nginx” server running inside a Docker container.

Your “default.conf” which is sometimes called a virtual hosts file should look like as shown below.

Important, as this a universal solution for deploying WordPress with one click, we have the following possible options:

  1. Local Deployment = Replace “DOMAIN_NAME” with “localhost” or “” or with some other “local IP Address“.
  2. Live Deployment = Replace “DOMAIN_NAME” with “Real Domain Name” like -> “” or you can also replace it with any “Public IP Address“.

Make sure you have your “DOMAIN_NAME” mapped to the “IP Address” of the machine/OS/system/instance you are running this project on.

an example for virtual hosts or extra conf file in nginx
An example for virtual hosts or extra “conf” file in Nginx

For convenience, you can copy the above configuration file from the box below:

server {
    listen 80;
    server_name DOMAIN_NAME;

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

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

    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;

Step 9: Now, it time to provide a reliable and error-free main configuration file to our “Nginx” web server, we have a simple yet powerful example shown below.

main nginx.conf file example
Main “nginx.conf” file example

For convenience, you can copy the above “nginx.conf” configuration file from the box below:

user www-data;
worker_processes auto;
pid /run/;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;

http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        include /etc/nginx/mime.types;
        default_type application/octet-stream;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
        client_max_body_size 100M;
        gzip on;
        gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 6;
        gzip_buffers 16 8k;
        gzip_http_version 1.1;
        gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

Step 10: As “php” is going to play an important part in this project, we also have to provide a dedicated configuration to it as well, shown below is one example.

an example of php.ini file for wordpress installation
An example of “php.ini” file for WordPress installation

For convenience, you can copy the above “php.ini” configuration file from the box below:

;This sets the maximum amount of memory in bytes that a script is allowed to allocate
memory_limit = 128M

;The maximum size of an uploaded file.
upload_max_filesize = 100M

;Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
post_max_size = 100M


Step 11: Now that we have configured our environment, it is time to check whether both “docker” and “docker-compose” is installed or not.

To install “Docker“, run the following commands specifically for Debian and Ubuntu based systems:

curl -fsSL -o
sudo sh
sudo usermod -aG docker $USER

To install “docker-compose“, run the following commands, again specifically for Debian and Ubuntu based systems:

sudo apt install python3-pip
sudo pip3 install docker-compose
check whether docker and docker-compose is installed or not
Check whether “docker” and “docker-compose” is installed or not

Note: If you are using a “Real Domain” and used the same in the “default.conf” file above then make sure you have mapped it on the IP Address used by your cloud machine.

Step 12: In our case, we are using an EC2 instance, so we have to copy it IP Address from the AWS EC2 dashboard, as shown below.

check IP address of ec2 instance from dahboard
Check IP Address of EC2 instance from dashboard

Step 13: After copying the IP Address, open the control panel of your “domain’s” authority, in our case it is “GoDaddy” as shown below, and set the IP Address as we did. One more thing, if you want to access your particular website with a “” then you also have to add a “canonical name” under your DNS settings, shortened to “CNAME” in our case.

setup or map ip address to domain name on godaddy
Setup or map IP Address to domain name on godaddy

Step 14: Before proceeding further to our final steps have a look at our most important file of this project -> “docker-compose.yml

version: "3.7"
      image: wordpress:5.1.1-php7.3-fpm
         - type: bind
           source: ./wordpress
           target: /var/www/html
         - type: bind
           source: ./php-fpm/php.ini
           target: /usr/local/etc/php/conf.d/opcache-recommended.ini
         - WORDPRESS_DB_HOST=mysql
         - WORDPRESS_DB_USER=myuser
         - WORDPRESS_DB_PASSWORD=secret
         - WORDPRESS_DB_NAME=mydb
         - "9000"
      image: nginx
        - type: bind
          source: ./wordpress
          target: /var/www/html
        - type: bind
          source: ./nginx/default.conf
          target: /etc/nginx/conf.d/default.conf
        - type: bind
          source: ./nginx/nginx.conf
          target: /etc/nginx/nginx.conf
        - "80:80"
      image: mariadb
        - MYSQL_DATABASE=mydb
        - MYSQL_USER=myuser
        - MYSQL_PASSWORD=secret
        - MYSQL_ROOT_PASSWORD=docker

Step 15: Now after installation, it is time to bring wordpress lemp stack up, use the command used in the picture below.

running the docker-compose up d command
Running the “docker-compose up -d” command

Step 16: We can see the services used and running with the help of the following command.

check the service status by running docker-compose ps command
Check the service status by running “docker-compose ps” command

Step 17: This is a confirmation check step, you have to enter your particular “DOMAIN_NAME” or “Public IP Address” or “localhost” or “” or any other “local IP Address“.

You will be redirected from “<Entered thing>” to “<Entered thing>/wp-admin/install.php” as shown in the picture below, as we have entered “” and redirected to “” for WordPress installation.

wordpress initial installation page
WordPress initial installation page

Conclusion “One click WordPress set up”

Comment here