Adobe Introduces Powerful Generative AI Tools in Photoshop
Artificial Intelligence

Adobe Introduces Powerful Generative AI Tools in Photoshop Beta

by Veronica
June 1, 2023
2

Adobe Photoshop beta AI will take your creativity to the...

Read more
Adobe Photoshop's Generative Fill Feature

Exploring the Power of Adobe Photoshop’s Generative Fill Feature

June 1, 2023
ChatGPT app

The Easiest Way to Download ChatGPT App Free

June 1, 2023
Nvidia Unveils Futuristic Gaming Experience at Computex 2023

Nvidia Unveils Futuristic Gaming Experience at Computex 2023, Blending Gaming and AI

May 29, 2023
NVIDIA and Microsoft Partner to Accelerate AI

NVIDIA and Microsoft Partner to Accelerate AI

May 25, 2023
How to install Web LLM

How to Install Web LLM for Your Website

May 10, 2023
Cerebras-GPT

How Cerebras-GPT is Revolutionizing Natural Language Processing

May 12, 2023
Auto GPT How to Automate Task

Auto GPT: How to Automate Task and achieve your Goal

May 4, 2023
how to use Bard AI

How to Effectively Use Google BARD: A Beginner’s Guide

May 12, 2023
ChatGPT Shared Links

ChatGPT Shared Links: A New Way to Share Your Conversations

June 1, 2023
How to use Autogpt in web browser

How to use AutoGPT in web browser

May 4, 2023
Cloudbooklet
  • News
  • Artificial Intelligence
  • Linux
  • Google Cloud
  • AWS
No Result
View All Result
Cloudbooklet
  • News
  • Artificial Intelligence
  • Linux
  • Google Cloud
  • AWS
No Result
View All Result
Cloudbooklet
No Result
View All Result
Home Google Cloud

Install WordPress with Docker Nginx Reverse Proxy to Apache with SSL – Google Cloud

by Cloudbooklet
April 26, 2023
in Google Cloud
Reading Time: 11 mins read
Install WordPress with Docker Nginx Reverse Proxy to Apache with SSL - Google Cloud
Share on FacebookShare on TwitterShare on WhatsAppShare on Telegram

Install WordPress with Docker Nginx Reverse Proxy to Apache with SSL – Google Cloud. In this guide you are going to learn how to make a best performance setup with Docker, Docker Compose, Nginx, Apache, PHP7.4 and Let’s Encrypt to run WordPress on Ubuntu 20.04.

For WordPress database we will use a high performance external database server provided by Google (Cloud SQL).

You might also like

How to Setup SSH Keys on Ubuntu

How to Setup SSH Keys on Ubuntu 20.04

May 31, 2023
DragGAN AI editing Tool Install and Use DragGAN Photo Editor

DragGAN AI editing Tool Install and Use DragGAN Photo Editor

May 27, 2023

This setup is tested on Google Cloud Platform with a Compute Engine with a 1.75 GB RAM Machine running Ubuntu 20.04 boot image and a Cloud SQL instance with MySQL 5.7.

You can also make this setup in any cloud services like AWS or Azure or DigitalOcean or any dedicated servers.

Prerequisites

  • Running Compute Engine, see the Setting up Compute Engine Instance.
  • Follow this guide to Install Docker on Ubuntu 20.04.
  • For managing containers install Docker Compose on your server.
  • A n external database server, see how to set up Cloud SQL in Google Cloud.
  • Configure DNS to point the domain to the server to install SSL.

Once you have all the prerequisites done you can proceed to make the setup and configure WordPress.

Create Docker Compose YML File

SSH inside your server and start by creating a docker-compose.yml file.

sudo nano docker-compose.yml

Copy the entire contents below and paste it in the file.

Make sure to replace the below mentioned environment variables.

version: "3.8"
services:
    wordpress:
        container_name: wordpress
        image: wordpress:php7.4-apache
        restart: always
        stdin_open: true
        tty: true
        environment:
            WORDPRESS_DB_HOST: CLOUDSQL_IP
            WORDPRESS_DB_USER: database_user
            WORDPRESS_DB_PASSWORD: database_user_password
            WORDPRESS_DB_NAME: database_name
        volumes:
            - ./wordpress:/var/www/html
       
    nginx:
        container_name: nginx
        image: nginx:latest
        restart: unless-stopped
        ports:
            - 80:80
            - 443:443
        volumes:
            - ./nginx/conf:/etc/nginx/conf.d
            - ./certbot/conf:/etc/nginx/ssl
            - ./certbot/data:/var/www/html

    certbot:
        container_name: certbot
        image: certbot/certbot:latest
        command: certonly --webroot --webroot-path=/var/www/html --email [email protected] --agree-tos --no-eff-email -d domain.com -d www.domain.com
        volumes:
            - ./certbot/conf:/etc/letsencrypt
            - ./certbot/logs:/var/log/letsencrypt
            - ./certbot/data:/var/www/html 

Hit CTRL-X followed by Y and ENTER to save and exit the file.

Here are the configuration details.

  • version: Compose file version which is compatible with the Docker Engine. You can check compatibility here.
  • services: here we have 3 services named wordpress, nginx and certbot.
  • image: We use latest WordPress with PHP7.4, Apache, Nginx and Certbot images available in Docker hub.
  • volumes:
    • wordpress: we have configured this directory to be synced with the directory we wish to use as the web root inside the container.
    • conf.d: here we will place the Nginx configuration file to be synced with the default Nginx conf.d folder inside the container.
    • cedtbot/conf: this is where we will receive the SSL certificate and this will be synced with the folder we wish to inside the container.
    • ports: configure the container to listen upon the listed ports.
    • command: the command used to receive the SSL certificate.
  • environment: here we list all the environment variables that are available for the WordPress image.
    • CLOUDSQL_IP: Replace it with your external database IP address.
    • database_user: Replace it with your database user name
    • database_user_password: Replace it with your database user password.
    • database_name: Replace it with your database name.

Configure Nginx

As per the docker-compose.yml configuration we need to create the default.conf file inside the nginx/conf directory.

Create the directory besides your docker-compose.yml file to hold the configuration file.

sudo mkdir -p nginx/conf

Create a file named default.conf.

sudo nano nginx/conf/default.conf

Place the following configurations, here we use reverse proxy configuration to wordpress container running Apache.

server {
    listen [::]:80;
    listen 80;

    server_name domain.com www.domain.com;

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

    location ~ /.well-known/acme-challenge {
        allow all; 
        root /var/www/html;
    }

    location / {
        try_files $uri @apache;
    }

    location ~ ^/\.user\.ini {
        deny all;
    }

    location ~*  \.(svg|svgz)$ {
        types {}
        default_type image/svg+xml;
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location @apache {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass http://wordpress:80;
    }

    location ~[^?]*/$ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass http://wordpress:80;
    }

    location ~ \.php$ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass http://wordpress:80;
    }

    location ~/\. {
        deny all;
        access_log off;
        log_not_found off;
    }
} 

Hit CTRL-X followed by Y and ENTER to save and exit the file.

Now you have your docker compose configuration and your Nginx configuration.

Start Containers

Start the containers using the following command, you will receive the SSL certificates once the containers are started.

docker-compose up -d

Once all containers are started you will see two additional directories certbot and wordpress created alongside your docker-compose.yml file.

The directory wordpress holds all your WordPress website source code.

The directory certbot holds all the files related to your SSL certificates.

To view the containers you can execute the following command.

docker-compose ps

Configure Let’s Encrypt SSL

As you have received the Let’s Encrypt SSL certificate you can configure HTTPS and setup redirection to HTTPS.

Edit the default.conf and make the following changes.

sudo nano nginx/conf/default.conf
server {
    listen [::]:80;
    listen 80;

    server_name domain.com www.domain;

    return 301 https://www.domain.com$request_uri;
}

 server {
    listen [::]:443 ssl http2;
    listen 443 ssl http2;

    server_name domain.com;

    ssl_certificate /etc/nginx/ssl/live/domain.com/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/live/domain.com/privkey.pem;
    
    return 301 https://www.domain.com$request_uri;
}

server {
    listen [::]:443 ssl http2;
    listen 443 ssl http2;

    server_name www.domain.com;

    ssl_certificate /etc/nginx/ssl/live/domain.com/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/live/domain.com/privkey.pem;

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

    location ~ /.well-known/acme-challenge {
         allow all; 
         root /var/www/html;
    }

    location / {
        try_files $uri @apache;
    }

    location ~ ^/\.user\.ini {
        deny all;
    }

    location ~*  \.(svg|svgz)$ {
        types {}
        default_type image/svg+xml;
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location @apache {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass http://wordpress:80;
    }

    location ~[^?]*/$ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass http://wordpress:80;
    }

    location ~ \.php$ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass http://wordpress:80;
    }

    location ~/\. {
        deny all;
        access_log off;
        log_not_found off;
    }
} 

Hit CTRL-X followed by Y and ENTER to save and exit the file.

Now restart the Nginx service to load the new configurations.

docker-compose restart nginx

Now you can check your domain name. You will get a redirection to HTTPS and you will see the WordPress installation page to complete the installation.

Learn the most Advanced Techniques of WordPress with this easy to learn course now.

Conclusion

Now you have learned how to install and setup WordPress with Nginx, Apache, PHP 7.4 and Let’s Encrypt with Docker on Ubuntu 20.04.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Tags: DockerGoogle Cloud PlatformUbuntu 20.04
Share1Tweet1SendShare
Cloudbooklet

Cloudbooklet

Help us grow and support our blog! Your contribution can make a real difference in providing valuable content to our readers. Join us in our journey by supporting our blog today!
Buy me a Coffee

Related Posts

Set Up Deep Learning with Nvidia, Cuda, cuDNN on Ubuntu

How to Set Up Deep Learning with Nvidia, CUDA, cuDNN on Ubuntu 22.04

May 27, 2023
How to Install or Upgrade PHP 8.2 on Ubuntu 22.04

How to Install or Upgrade PHP 8.2 on Ubuntu 22.04

June 1, 2023
How to Change Timezone on Ubuntu 22.04

How to Change Timezone on Ubuntu 22.04

May 16, 2023
How to Install Ansible on Ubuntu 22.04

How to Install Ansible on Ubuntu 22.04

May 19, 2023

Comments 3

  1. Nigel says:
    2 years ago

    Under Site Health Status I get:

    The REST API request failed due to an error.
    Error: cURL error 7: Failed to connect to mydomain port 443: Connection refused (http_request_failed)

    Thanks

    Reply
  2. Andre says:
    3 years ago

    Hello guys!

    Well, first of all I would like to say that your website has become a reference for me.
    Thank you very much for sharing so didactically valuable and updated information. They are generous!

    But, I have a beginner’s question:

    I even understand why port 80 conflicts with Apache and Nginx, but normally I stop port 80 from Apache or Nginx. Do you have any other solution, say that you have “good technical practice”?

    Thank you!

    André

    Reply
    • Cloudbooklet says:
      3 years ago

      Hi Andre,

      Thank you for using Cloudbooklet. While you use Docker containers for Nginx and Apache the port 80 wont get any conflict because they the two web servers are in separate containers and they both can be accessible using port 80. If you dont use container setup then you will face the conflict.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

I agree to the Terms & Conditions and Privacy Policy.

  • Trending
  • Comments
  • Latest
DragGAN The AI-Powered Image Editing Tool

DragGAN: The AI-Powered Image Editing Tool That Makes Editing Images Easy

May 30, 2023
DragGAN AI editing Tool Install and Use DragGAN Photo Editor

DragGAN AI editing Tool Install and Use DragGAN Photo Editor

May 27, 2023
Bard API key

Everything You Need to Know About Google’s Bard API Key

May 20, 2023
Install PHP 8.1 on Ubuntu

How to Install or Upgrade PHP 8.1 on Ubuntu 20.04

May 17, 2023
DragGAN The AI-Powered Image Editing Tool

DragGAN: The AI-Powered Image Editing Tool That Makes Editing Images Easy

79
Upgrade PHP version to PHP 7.4 on Ubuntu

Upgrade PHP version to PHP 7.4 on Ubuntu

28
Install Odoo 13 on Ubuntu 18.04 with Nginx - Google Cloud

Install Odoo 13 on Ubuntu 18.04 with Nginx – Google Cloud

25
Best Performance WordPress with Google Cloud CDN and Load Balancing

Best Performance WordPress with Google Cloud CDN and Load Balancing

23
Best PHP-FPM Configuration - Easy and Simple Calculation

Best PHP-FPM Configuration – Easy and Simple Calculation

June 1, 2023
ChatGPT Shared Links

ChatGPT Shared Links: A New Way to Share Your Conversations

June 1, 2023
Deepfake

Deepfake: The Rise of Synthetic Media

June 1, 2023
How to Setup SSH Keys on Ubuntu

How to Setup SSH Keys on Ubuntu 20.04

May 31, 2023

Popular Articles

  • DragGAN The AI-Powered Image Editing Tool

    DragGAN: The AI-Powered Image Editing Tool That Makes Editing Images Easy

    1521 shares
    Share 608 Tweet 380
  • DragGAN AI editing Tool Install and Use DragGAN Photo Editor

    402 shares
    Share 161 Tweet 101
  • Auto-Photoshop-Stable Diffusion-Plugin: A New Way to Create AI-Generated Images in Photoshop

    71 shares
    Share 28 Tweet 18
  • InternGPT: A New Way to Interact with ChatGPT

    56 shares
    Share 22 Tweet 14
  • Microsoft research Reveals GPT-4 AI Shows Promising Signs of Common Sense and Human-Like Reasoning

    100 shares
    Share 40 Tweet 25
Latest Technology Trends in Artificial Intelligence and Machine Learning with Cloudbooklet

Welcome to our technology blog, where we explore the latest advancements in the field of artificial intelligence (AI) and how they are revolutionizing cloud computing. In this blog, we dive into the powerful capabilities of cloud platforms like Google Cloud Platform (GCP), Amazon Web Services (AWS), and Microsoft Azure, and how they are accelerating the adoption and deployment of AI solutions across various industries. Join us on this exciting journey as we explore the endless possibilities of AI and cloud computing.

  • About
  • Contact
  • Disclaimer
  • Privacy Policy

Cloudbooklet © 2023 All rights reserved.

No Result
View All Result
  • News
  • Artificial Intelligence
  • Linux
  • Google Cloud
  • AWS

Cloudbooklet © 2023 All rights reserved.

This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.