Azure App Service Team Blog

How the App Service team functions

Create WordPress using Web Apps on Linux

Web Apps on Linux(Preview) allows running web apps natively on Linux. WordPress is popular blogging platform primarily used on Linux distributions.  Today we have released WordPress for App Service on Linux in the Azure marketplace that helps you quickly create a WordPress application on Web apps (Linux) . Azure App service on Linux lets you bring your own custom image and this template leverages the same for using a custom docker image for WordPress publicly available on docker hub .

wplinux3

This docker image enables you to run a WordPress site on Azure Web App on Linux  using either :

  1. ClearDB : It is Microsoft Partner solution for a fully integrated MySQL service on Azure. Purchasing a paid MySQL database may require a credit card be associated with your Azure subscription.
  2. Azure Database for MySQL(Preview) : It is a Microsoft solution for MySQL service on Azure that provides a managed database service for app development and deployment that allows you to stand up a MySQL database in minutes and scale on the fly .
  3. MySQL in-app : This uses the Maria DB database included in the image. This option is recommended for development purposes and does not scale on multiple instances.

Before you begin

If you don’t have an Azure subscription, create a free account before you begin.

Deploy from Marketplace

Log in to the Azure portal.Click here to create the WordPress application.wordpress-linux

Name Description
App Name
Enter a unique app name for your **Web App Name**. This name is used as part of the default DNS name for your app <app_name>.azurewebsites.net, so it needs to be unique across all apps in Azure. You can later map a custom domain name to your app before you expose it to your users
Subscription Select a Subscription. If you have multiple subscriptions, choose the appropriate subscription.
Resource group
Enter a resource group. A resource group is a logical container into which Azure resources like web apps, databases that is deployed and managed. You can create a resource group or use an existing one
App Service Plan
App Service plans represent the collection of physical resources used to host your apps. Select the Location and the Pricing tier. For more information on pricing, see App service pricing tier 
Database Provider Select one of the three options for MySQL : ClearDB , Azure Database for MySQL (Preview) or MySQL in-app. Complete the Database configuration based on your choice.

This will deploy a WordPress custom image on to Web Apps on Linux . Note there might be cold start for the first request to the site created.

Local database connection information

All the database information is stored in your web app application settings. The password, database name are auto generated . You can find this information in the Azure portal , select your web app -> Application settings -> app settings

Name Default Value
DATABASE_HOST 127.0.0.1
DATABASE_NAME <auto-generated string>
DATBASE_USERNAME wpadmin
DATABASE_PASSWORD <auto-generated string>
TABLE_NAME_PREFIX wp_
PHPMYADMIN_USERNAME phpmyadmin
PHPMYADMIN_PASSWORD <auto-generated string>

Connect to local MariaDB database

If you’re using the builtin MariaDB, you can access the builtin phpMyAdmin site with a URL like below:  http://hostname[:port]/phpmyadmin

Manage ClearDB or Azure Service for MySQL(Preview) database

If you’re using the Azure Service for MySQL(Preview) , you can manage your database with MySQL workbench or MySQL utilities.

Connect to local redis cache

If you’re using the builtin MariaDB, you can leverage the builtin redis cache server with WordPress cache plugins. For example, the Redis Object Cache. The builtin Redis cache server uses port 6379. It is recommend to use Azure Redis cache for production site.

Limitations

There are some limitations with using this image on Web Apps on Linux.  These are components included with this image .

  1. WordPress 4.7.2
  2. PHP 7.1.2
  3. Apache HTTPD 2.4.25
  4. MariaDB 10.0+
  5. Redis3.2.8
  6. phpMyAdmin 4.6.6

Keep this in mind when using the template with your application when using MySQL in-app (Local Database)

  • You CANNOT scale out your site to multiple instances, if you deploy a WordPress site on Azure with this docker image and use the MariaDB built in this docker image as the database. Since the database is local , the solution ONLY supports running on ONE instance. 
  • The Redis cache built in this docker image is available only when you use the MariaDB built in this docker image as the database. Since redis cache is local , this should be used only with local MariaDB database on a single isntance web app.
  • The phpMyAdmin built in this docker image is available only when you use the MariaDB built in this docker image as the database.

Migrating an existing WordPress site

This image creates a new WordPress application every time it is deployed. If you are migrating your application to this site , please follow directions to export and import as mentioned on WordPress Codex.

If you have a complex WordPress application where the above mentioned export and import options are not effective, Web Apps on Linux supports git deployment and you use FTP  or GIT deployment to replace the file system on the site created with this template to bring your own content. You can use PHPmyadmin available with this solution to import your application database content.

Troubleshooting

Recent updates to the docker image  for WordPress on Linux may impact your site. If you created your WordPress app before 4/21 :

  1. Update the app settings and restart your site.
Name Default Value
DATABASE_HOST 127.0.0.1
DATABASE_NAME <auto-generated string>
DATABASE_USERNAME wpadmin
DATABASE_PASSWORD <auto-generated string>
TABLE_NAME_PREFIX wp_

2. Replace DOCKER_CUSTOM_IMAGE setting to LinuxFxVersion = DOCKER|appsvc/apps:wordpress:0.1