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.

Table of Contents
- Prerequisites
- Create App Service (Linux)
- Create & Configure MySQL Database Server on Azure
- Deploy WordPress on Azure App Service (Linux)
- Configure WordPress Installation
- Run the Installation of WordPress on Azure App Service
- Configure SSL for WordPress on Azure (Important Step)
- Scale Up/Down Azure App Service Plan
- Point Azure App Service to a Custom Domain
- Azure Subscription Cost Analysis
- Video
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.4asRuntime Stack - Select
LinuxasOperating System - Select the Region that is closer to the users of your Web App
- Give a name for
App Service Planthat you want to create - Change the
App Service Plan SKUaccording 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 MySQLthat appears inServicessection of search result - Click on Add button with + sign to create a new
Azure Database for MySQL - On the
Create MySQL serverblade underBasicstab, 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
Subscriptionwhere you want to create the MySQL database server - Choose the
Resource Groupif you already have or clickCreate newto 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 DatabaseServer nameafterwards - Choose
Data sourceasNone - Choose a nearest
Locationwhere 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
Versionas5.7 - Choose the
Compute + storageaccording to your needs. Click onConfigure serverand explore various availablePricing tiers. - For the demonstration purposes, I’m choosing
Basicwith 1vCoreand 5 GBStorageand toggle theStorage Auto-growthset toNoand click onOK - 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 usernameof 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
PasswordandConfirm Passwordthat 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
ENABLEDunless you want to turn it off for obvious reasons. - Finally, click on
Savebutton located at the top of theConnection securitypage.
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 Workbenchinstalled on your local PC - Click on
+icon that will open theSetup New Connectionpop up window - Provide a Connection name of your choice
- Leave the
Connection Methodto defaultStandard (TCP/IP) - Under
Parameterstab provideHostnamewith value ofServer namefield that is present in the Overview blade of Azure Database Server - Leave the
Portas is to default3306 - Provide the
Usernamewith the value labelled asServer admin login nameobtained from Azure Database server’s Overview blade - Provide
Passwordby clicking onStore in Vault...button and input thePasswordwith value given when creating Administrator account and click onOK - If you forgot the password, in Overview pane of Azure database for MySQL server, locate and click
Reset passwordand then providePasswordandConfirm passwordand save it and provide the same in password text box ofStore Password For Connectionwindow of the MySQL WorkbenchStore in Vault...option - Leave the
Default Schemaoption empty - Navigate to the
SSLtab and forUse SSLchooseRequireoption if you haveEnforce SSLset toEnabledwhich could be found inConnection Securityblade ofAzure database for MySQL - Click on the button
Test Connectionto 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
Navigatorpane of MySQL Workbench, locateSCHEMASsection. - Right click on the default
sysschema and clickCreate Schema... - In the Schema creation page that opens in the main window, provide
Nameof the new schema such aswordpress_database - Click on
Applyand then a pop up appears to confirmApply 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 ToolslocateSSHand click on it - In the detailed blade of
SSH, click on the hyperlinkGo ->to openSSHinstance 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 Nameis the new database schema that we created in MySQL WorkbenchUsernamecan be found viaOverviewblade ofAzure database for MySQL serverlabelled asServer admin login namePasswordis the password provided when creating the Administrator account. If you forgot password, you can reset it form theReset passwordoption available at the top of the Overview blade ofAzure database for MySQL serverDatabase Hostcan be found viaOverviewblade ofAzure database for MySQL serverlabelled asServer name- Leave the
Table Prefixas 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 Titletext box, provide a suitable name for your site - Provide a
UsernameandPassword. These are the credentials that could be used to access the WordPress Admin Dashboard which is typically available on urlyour-web-app-name.azurewebsites.net/wp-admin - Provide
Your Emailsuch that it could be used to send notifications, alerts and forgot passwords requests. - Leave the option
Search Engine Visibilityas un-checked - Click on
Install WordPressbutton to begin the installation. - Once the installation completes, login with
Username or Email AddressandPasswordprovided 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 SettingsswitchHTTPS onlyflagOn
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 SSLplugin - In Really Simple SSL
Configurationclick onGo ahead, activate SSL - In settings of the Really Simple SSL plugin
EnableWordPress 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
Settingslocate and click onScale up (App Service plan) - Choose the proper workload of your choice, say,
- either a
Standard Production workloadofS1V1with 1.75 GB memory and 100 total ACU that supports an Auto Scale of up to 10 instances subject to availability - or
Premium Production workloadofP1V2with 3.5 GB memory with 210 total ACU that supports an Auto Scale of up to 20 instances subject to availability
- either a
- 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
You can go through this detailed video that will guide you to Host WordPress on Azure (Step by Step Tutorial)
Pingback: Here is How my Azure bill looks like for the past four months – TutLinks