How to install Wordpress server based on Azure Web App

From PUBLIC-WIKI
Jump to navigation Jump to search

How to install Azure CLI Tools

  • Login to the machine using privileged account.
  • Download the latest build of Azure CLI.
  • Windows download instruction and location:
https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest
  • Linux download instruction and location:
https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?view=azure-cli-latest

How to login to an Azure subscription

  • Login to an Azure account, from command prompt:
az login
  • Run the command below to list the available subscriptions:
az account list --output table
  • Run the command below to change the context to a specific Azure subscription:
az account set --subscription "MySubscription"
Note: Replace “MySubscription” with the relevant subscription name
  • Run the command below to verify the currently selected Azure subscription:
az account show

Installation phase

  • Run the command below to create a new resource group:
az group create --name MyResourceGroup --location MyLocation
Note 1: Replace MyResourceGroup with your own relevant group name
Note 2: Replace MyLocation with the target location, from the list below:
https://azure.microsoft.com/en-us/global-infrastructure/locations/
  • Run the command below (as a single line) to create a new Azure App Service plan:
az appservice plan create -n wordpressappservice -g MyResourceGroup -l MyLocation --is-linux --sku S1
Note 1: Replace wordpressappservice with your own app service plan name (Alphanumeric, without space or special characters)
Note 2: Replace MyResourceGroup with the previously create resource group
Note 3: Replace MyLocation with the same region as the resource group
  • Run the command below (as a single line) to create a new MySQL database:
az mysql server create -g MyResourceGroup -n MyDBServerName --admin-user MyDBUserName --admin-password "MyDBPassword" -l MyLocation --ssl-enforcement Disabled --sku-name B_Gen5_1 --version 5.7
Note 1: Replace MyResourceGroup with the previously create resource group
Note 2: Replace MyDBServerName with your own MySQL server name
Note 3: Replace MyDBUserName with your own MySQL username
Note 4: Replace MyDBPassword with a complex password for the MySQL database account
Note 5: Replace MyLocation with the same region as the resource group
  • Run the command below (as a single line) to configure firewall rule for accessing the MySQL database:
az mysql server firewall-rule create -g MyResourceGroup --server MyDBServerName --name AllowAppService --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0
Note 1: Replace MyResourceGroup with the previously create resource group
Note 2: Replace MyDBServerName with your own MySQL server name
  • Run the command below to create a new database for the Wordpress application:
az mysql db create --resource-group MyResourceGroup --server-name MyDBServerName --name MyWordPressDBName
Note 1: Replace MyResourceGroup with the previously create resource group
Note 2: Replace MyDBServerName with your own MySQL server name
Note 3: Replace MyWordPressDBName with your own custom WordPress database name
  • Run the command below (as a single line) to configure the Wordpress App service:
az webapp create -n MyAppServiceName -g MyResourceGroup --plan wordpressappservice -i "wordpress"
Note 1: Replace MyAppServiceName with your own app service name
Note 2: Replace MyResourceGroup with the previously create resource group
  • Run the command below (as a single line) to configure the WordPress App service database connection settings:
az webapp config appsettings set -n MyDBServerName -g MyResourceGroup --settings WORDPRESS_DB_HOST= MyDBServerName.mysql.database.azure.com WORDPRESS_DB_USER="MyDBUserName@MyDBServerName.mysql.database.azure.com" WORDPRESS_DB_PASSWORD="MyDBPassword"
Note 1: Replace MyDBServerName with your own MySQL server name
Note 2: Replace MyResourceGroup with the previously create resource group
Note 3: Replace MyDBUserName with your own MySQL username
Note 4: Replace MyDBPassword with a complex password for the MySQL database
  • Exit the command prompt
  • Login to the Azure portal:
https://portal.azure.com
  • From the left pane, click on Resource Groups -> select the newly created resource group -> from the main pane, click on Tags:
  • Name: Specify here “Project”
  • Value: Specify here a value to represent the project name
  • Click on Save
  • From the upper search field, write “App Service plans” -> Select the newly create service plan -> From the main pane, click on “Tags”:
  • Name: Specify here “Project”
  • Value: Specify here a value to represent the project name
  • Click on Save
  • From the upper search bar of the Azure portal, write “Azure Database for MySQL servers” -> click to enter the properties of the newly created MySQL database -> From the main pane, click on “Tags”:
  • Name: Specify here “Project”
  • Value: Specify here a value to represent the project name
  • Click on Save
  • From the upper search bar of the Azure portal, write “App Services” -> Select the newly create App services:
  • From the Overview page, write down the URL
  • From the Tags page:
  • Name: Specify here “Project”
  • Value: Specify here a value to represent the project name
  • Click on Save
  • Exit the Azure portal

WordPress initial configuration

  • Open a browser and specify the FQDN name of the Wordpress app service.
  • From the language selection page, select English and click Continue
  • Click on “Let’s go!”
  • From the Welcome wizard page:
  • Specify the web site title
  • Specify your own username
  • Write down the password and store it in a safe location
  • Specify an email address for notifications (prefer to use a mailing list)
  • Click Install WordPress