Easily Deploy WordPress on Azure App Service (A Concise Guide for Azure Architects)

In this tutorial we will deploy WordPress on Azure App Service for Linux. Though there are many ways to deploy WordPress on Azure like deploying Bitnami WordPress and WordPress for Azure, we will go on traditional web deployment approach to have full control over the app resources on Azure.

This article aims for Azure Architects who want to learn various features of Azure Cloud ☁️ that are common to any web application being hosted on Azure App Service. This includes how to access SSH of Azure App Service, configuring SSL 🔒 for a web application hosted on Azure App Service and how to scale web application for various workloads and much more.

Deploy WordPress on Azure App Service – TutLinks
Deploy WordPress on Azure App Service – TutLinks

Table of Contents

Prerequisites

If you want to follow along with the tutorial, it is recommended for you to satisfy the below set of Prerequisites.

  • A PC with Internet connectivity
  • A Web Browser (Firefox is recommended 🦊 To help browse web app and configure SSL 🔒 properly)
  • Active Azure ☁️ Account that permits you to create App Service Plans
  • Basic Knowledge of web hosting and WordPress Hosting

Create App Service (Linux)

We will create an Azure App Service with Linux OS and PHP 7.3 Runtime stack. This will facilitate us to host PHP based popular CMS WordPress. Follow the steps to create App Service on Azure.

  • Click on Wrench Icon and then Create Resource
  • Under Web Choose Web App
  • Select an existing Resource Group or create a new Resource Group
  • Give the name of the App Service. You can access the Web App with your-web-app-name.azurewebsites.net
  • Select PHP 7.4 as Runtime Stack
  • Select Linux as Operating System
  • Select the Region that is closer to the users of your Web App
  • Give a name for App Service Plan that you want to create
  • Change the App Service Plan SKU according to your budget and needs. I chose B1 Basic that has support for SSL and Custom Domains
  • Click on Review and then Create App Service

Wait for the Azure App Service to be created. You will be prompted with an alert once the App Service is created successfully. So you can do other tasks on the Azure Portal.

Create & Configure MySQL Database Server on Azure

As the WordPress CMS uses MySQL database as the database server to store data that is generated in the form of Posts, Pages and comments etc,. We will create a new Azure Database for MySQL. We will also configure our database server in such a way that

  • it can be able to connect to all web apps hosted on Azure
  • it should allow connections from MySQL Workbench installed on your local PC to Azure database for MySQL.

We will first perform the following steps to create an Azure Database for MySQL.

Create a Database for WordPress in MySQL Server

  • In the Search bar located at the top of Azure Portal, type MySQL and select the Azure Database for MySQL that appears in Services section of search result
  • Click on Add button with + sign to create a new Azure Database for MySQL
  • On the Create MySQL server blade under Basics tab, fill in the necessary info

Project Details

It is better to choose the same Resource Group as the one chosen/created for App Service where you want to deploy WordPress.

  • In case you have multiple subscriptions, choose the Subscription where you want to create the MySQL database server
  • Choose the Resource Group if you already have or click Create new to add a new resource group

Server Details

Provide the server details and locations and choose Compute and storage as applicable. To do so, perform the following steps.

  • Give a meaningful and available Server name. You cannot change the Azure Database Server name afterwards
  • Choose Data source as None
  • Choose a nearest Location where your user base is geographically located. Doing so will have a significant impact in the response time between the calls that happen from web app to the database
  • Select the MySQL server Version as 5.7
  • Choose the Compute + storage according to your needs. Click on Configure server and explore various available Pricing tiers.
  • For the demonstration purposes, I’m choosing Basic with 1 vCore and 5 GB Storage and toggle the Storage Auto-growth set to No and click on OK
  • Ensure that your chosen configuration reflects on Compute + storage

Please note that changing to and from the Basic compute tier or changing the backup redundancy options after server creation is not supported.

Administrator account

Create an Administrator account to access the Azure Database for MySQL by performing the following steps.

  • Provide Admin username of your choice that meets the satisfying criterion set by Azure
    • The value should not be empty.
    • Admin username must be at least 1 characters and at most 16 characters.
    • Admin username must only contain characters and numbers.
  • Provide Password and Confirm Password that meets the satisfying the following criterion set by Azure for Passwords
    • The value should not be empty.
    • Your password must be at least 8 characters and at most 128 characters.
    • Your password must contain characters from three of the following categories – English uppercase letters, English lowercase letters, numbers (0-9), and non-alphanumeric characters (!, $, #, %, etc.).

Once you are done providing these details, click on Review + create. Later click on Create once the final validation performed by the server creation wizard succeeds. The MySQL Server creation typically takes 6-8 minutes to be created on and you can perform other tasks until you get notified of the status of creation.

Configure Azure Database for MySQL

Navigate to the MySQL server created and you will be landed on Overview page. Under Settings click on Connection security

Allow access to Azure services

If you want this database server to be access by all Azure Services across Azure Portal including the resources that are not in active subscription where this server lies, toggle the Allow access to Azure services to Yes. I’ll leave it as No which is default as my web app will be within the same subscription that of the database server.

Enable access to Azure database for MySQL server to allow connections via MySQL Workbench on local PC

In order for you to access the database server on your PC via MySQL Workbench, then click on Add client IP located at the top of the Connection security page. This will add a Firewall rule name with the IP address of your PC / Laptop from where you want to access this database server via MySQL Workbench.

  • Leave the Enforce SSL settings to ENABLED unless you want to turn it off for obvious reasons.
  • Finally, click on Save button located at the top of the Connection security page.

Connect Azure MySQL Database from MySQL Workbench

To provide values for Connection details, open the Overview page of the MySQL database server on Azure and perform the following steps.

  • Open MySQL Workbench installed on your local PC
  • Click on + icon that will open the Setup New Connection pop up window
  • Provide a Connection name of your choice
  • Leave the Connection Method to default Standard (TCP/IP)
  • Under Parameters tab provide Hostname with value of Server name field that is present in the Overview blade of Azure Database Server
  • Leave the Port as is to default 3306
  • Provide the Username with the value labelled as Server admin login name obtained from Azure Database server’s Overview blade
  • Provide Password by clicking on Store in Vault... button and input the Password with value given when creating Administrator account and click on OK
  • If you forgot the password, in Overview pane of Azure database for MySQL server, locate and click Reset password and then provide Password and Confirm password and save it and provide the same in password text box of Store Password For Connection window of the MySQL Workbench Store in Vault... option
  • Leave the Default Schema option empty
  • Navigate to the SSL tab and for Use SSL choose Require option if you have Enforce SSL set to Enabled which could be found in Connection Security blade of Azure database for MySQL
  • Click on the button Test Connection to validate handshake from local PC MySQL Workbench to Azure database for MySQL
  • Click on OK

Create a database Schema for WordPress

We will create a database schema in the Azure Database for MySQL server so that it could be used by our WordPress application hosted on Azure App Service. Azure Database for MySQL allows creation of unlimited databases. But it comes at the cost of shared resources spread across the databases.

As we have connected to the Azure database for MySQL via MySQL Workbench, lets create a schema to be consumed by WordPress application.

  • In the Navigator pane of MySQL Workbench, locate SCHEMAS section.
  • Right click on the default sys schema and click Create Schema...
  • In the Schema creation page that opens in the main window, provide Name of the new schema such as wordpress_database
  • Click on Apply and then a pop up appears to confirm Apply SQL Script to Database
  • Confirm the creation of new schema again by clicking on Apply
  • Save the name of the new schema created, which will be used when installing WordPress and Configuration of initial steps.

Deploy WordPress on Azure App Service (Linux)

Access Secure Shell (SSH) of Azure App Service

  • Open the App Service created to deploy WordPress
  • Under Development Tools locate SSH and click on it
  • In the detailed blade of SSH, click on the hyperlink Go -> to open SSH instance connected to the App Service in a new tab.

Download latest WordPress to Azure App Service

Run the following scripts in the Secure Shell to download the latest WordPress archive.

cd /home/site/wwwroot
wget -c http://WordPress.org/latest.tar.gz
tar -xzvf latest.tar.gz
mv WordPress/* /home/site/wwwroot/
rm -rf WordPress
rm -rf latest.tar.gz

Configure WordPress Installation

Now open the App Service and on the Overview blade locate Browse button that will launch your-web-app-name.azurewebsites.net in a new tab. Perform the following steps to configure our WordPress installation. This is one time activity so keep your database connection parameters such as server name/host name, database schema name and credentials such as admin user name and password handy.

Navigate to the database connection details page and provide following details

  • Database Name is the new database schema that we created in MySQL Workbench
  • Username can be found via Overview blade of Azure database for MySQL server labelled as Server admin login name
  • Password is the password provided when creating the Administrator account. If you forgot password, you can reset it form the Reset password option available at the top of the Overview blade of Azure database for MySQL server
  • Database Host can be found via Overview blade of Azure database for MySQL server labelled as Server name
  • Leave the Table Prefix as is, unless you want to have custom table prefix
  • Click on Submit

Run the Installation of WordPress on Azure App Service

You will be asked for a confirmation and then click on Run the installation to perform the installation of WordPress on Azure App Service. Once you land on Welcome screen, provide the necessary information by following the instruction below.

  • In the Site Title text box, provide a suitable name for your site
  • Provide a Username and Password. These are the credentials that could be used to access the WordPress Admin Dashboard which is typically available on url your-web-app-name.azurewebsites.net/wp-admin
  • Provide Your Email such that it could be used to send notifications, alerts and forgot passwords requests.
  • Leave the option Search Engine Visibility as un-checked
  • Click on Install WordPress button to begin the installation.
  • Once the installation completes, login with Username or Email Address and Password provided during installation of WordPress.
  • You will be landed on Admin dashboard where you have full control over the WordPress installation.
  • Try installing plugins and creating Posts or Pages.

Configure SSL for WordPress on Azure (Important Step)

Enable HTTPS only Protocol On App Service

  • Navigate to App Service
  • Click on Settings
  • Locate TLS/SSL Settings
  • Under Protocol Settings switch HTTPS only flag On

Install Really Simple SSL Plugin for WordPress

Once you enable HTTPS only protocol on Azure App Service, you will have trouble browsing the WordPress installation and hence it is suggested to use login to WordPress Admin Dashboard via FireFox browser and keep doing below mentioned steps for every improperly rendered page

  • click on the lock 🔒 icon in the URL bar of Firefox browser
  • Click the arrow next to Connection Security
  • Click on the button disable protection for now

In WordPress admin dashboard, perform the following steps to install Really Simple SSL plugin.

  • Go to add plugins and install Really Simple SSL plugin
  • In Really Simple SSL Configuration click on Go ahead, activate SSL
  • In settings of the Really Simple SSL plugin Enable WordPress 301 redirection to SSL

Scale Up/Down Azure App Service Plan

As your website begin to attract more visitors, the WordPress need to handle high bandwidth and hence you need to add more CPU or processing power to your application. You can do that by performing the following steps.

  • Navigate to Azure App Service where you have deployed WordPress
  • Under Settings locate and click on Scale up (App Service plan)
  • Choose the proper workload of your choice, say,
    • either a Standard Production workload of S1V1 with 1.75 GB memory and 100 total ACU that supports an Auto Scale of up to 10 instances subject to availability
    • or Premium Production workload of P1V2 with 3.5 GB memory with 210 total ACU that supports an Auto Scale of up to 20 instances subject to availability
  • Click on Apply

Point Azure App Service to a Custom Domain

You need to own a custom domain either registered directly on Azure Portal or registered from third party websites such as GoDaddy or NameCheap. Once you own a domain name, you can Map the Custom Domain to Azure App Service. Follow the below references mentioned below to Register and Map Custom Domains to Azure App Service.

Register a Domain on Azure App Service

If you want to point your WordPress to a custom domain I recommend you to check out my other videos on registering a custom domain on Azure.

Map Custom Domain purchased on GoDaddy to Azure App Service

If you have an already existing domain purchased from the registrar like GoDaddy, you can check out the video on mapping a custom domain from GoDaddy to an Azure App Service.

Azure Subscription Cost Analysis

In case you are interested in understanding how much does it costs to host a WordPress on Azure, it may probably be around $50 as per the details mentioned in this article Here is How my Azure bill looks like for the past four months. But its not a straight $50 bill generated by Azure for just single instance of WordPress. I have explained in detail about how I am hosting multiple websites and APIs and also detailed about the infrastructure I am maintaining to host multiple Azure App Services and an Azure Database Server and DNS Zones.

Video

Hosting WordPress On Azure (Step by Step Tutorial) – TutLinks

You can go through this detailed video that will guide you to Host WordPress on Azure (Step by Step Tutorial)

Navule Pavan Kumar Rao

I am a Full Stack Software Engineer with the Product Development experience in Banking, Finance, Corporate Tax and Automobile domains. I use SOLID Programming Principles and Design Patterns and Architect Software Solutions that scale using C#, .NET, Python, PHP and TDD. I am an expert in deployment of the Software Applications to Cloud Platforms such as Azure, GCP and non cloud On-Premise Infrastructures using shell scripts that become a part of CI/CD. I pursued Executive M.Tech in Data Science from IIT, Hyderabad (Indian Institute of Technology, Hyderabad) and hold B.Tech in Electonics and Communications Engineering from Vaagdevi Institute of Technology & Science.

This Post Has One Comment

Leave a Reply