WordPress with SQL Azure
The Cloud Zone is brought to you in partnership with Iron.io. Discover how Microservices have transformed the way developers are building and deploying applications in the era of modern cloud infrastructure.
Windows Azure supports WordPress out of the box. But what is little-known are the limitations of this solution:
- The maximum size of the WordPress database is 20MB.
- The MySQL database is provided by ClearDB, not Microsoft. In order to raise the limit, one must purchase a plan (starting from $9.99/mo) through ClearDB.
Fortunately, it’s possible to skip the MySQL altogether and to run WordPress with SQL Azure.
Officially WordPress supports only MySQL. But it has a rich set of different plugins and one of those plugins isWP Db Abstraction. The plugin makes it possible to run the site using a different database platform, in this case SQL Azure. On the Microsoft forums a forum member mouradl provided instructions on how to install and use the plugin. I took those instructions and built a GitHub repository which make the process of deploying a WordPress with SQL Azure a little easier.
The repository contains the following versions:
- WordPress 3.4.2
- WP Db Abstraction 1.1.4
The following tutorial shows how to run the WordPress using SQL Azure and Azure Web Sites.
Setting up a WordPress with SQL Azure requires only few steps:
- Creation of a SQL Azure database
- Creation of an empty Azure Web Site
- Deployment of the WordPress using Git
- The configuration
1. Creating the SQL Azure database
We start by creating an empty SQL Azure database using the Azure management portal. In this tutorial we use the following configuration:
- Name: WordPressSqlAzure
- Max size: 1GB
- Collation: SQL_Latin1_General_CP1_CI_AS
- Login name: wordpressuser
- Login password: Password32
- Region: West Europe
- Allow Windows Azure Services To Access The Server: Yes
It usually takes less than a minute before the SQL Azure database is ready. Open the database details and make note of the connection string:
- Server: co4h26putx.database.windows.net
2. Creating the empty Azure Web Site
Next thing required is an empty Azure Web Site. It’s best to create it to the same region as the database is created. In this tutorial the following definitions are used:
- URL: WordPressSiteSqlAzure
- Region: West Europe
At this point we have the empty Web site and the empty database ready.
3. The deployment of a WordPress site
Next step is to add the WordPress site into our web server. First, using the Azure Management Portal, enable the Git publishing for our newly created site. The required function is “Set up Git publishing”.
Take note of the web site’s Git URL:
The next part is little tricky as we have to first clone the WordPress-SQL-Azure repository from GitHub and then deploy it to the Azure.
Clone the repository from GitHub:
Push the files to Azure web site:
git push azure master
Now we have the required files on Azure. Only thing left is to configure our WordPress installation to work with the SQL Azure database.
4. The configuration
To configure the WordPress to work with SQL Azure, we must navigate to WP Db Abstraction plugins configuration page. The URL is http://url.azurewebsites.net/wp-content/mu-plugins/wp-db-abstraction/setup-config.php, so in this tutorial: http://wordpresssitesqlazure.azurewebsites.net/wp-content/mu-plugins/wp-db-abstraction/setup-config.php
From the welcome page select “Let’s go” to set the configuration. On this step we must set the details of our SQL Azure database:
- Database Name: WordPressSqlAzure
- User Name: wordpressuser
- Password: Password32
- Database Host: co4h26putx.database.windows.net
- Database Type: PDO SqlSrv
- Table Prefix: wp_
Make sure to select PDO SqlSrv as database type, not “SQL Server using MS PHP Driver”:
The configuration wizard makes sure that the connection works and gives the notification that everything is set up from the SQL Azure ‘s point of view:
Now everything is ready and the install wizard will automatically continue from the WordPress’ default installation. Give the site a name, enter a password and email and you’re all set!
Note about the plugins
Most of the WordPress plugins should work with SQL Azure but there are some which override the db.phpfile from wp-content –folder. This happens for example with the W3 Total Cache plugin. The easiest solution is to avoid these plugins (for example WP Super Cache works without modifications) but if the db.php gets replaces by some plugin, the fix is to use a FTP Client and to upload the db.php from wordpress-sql-azure repository to the site’s wp-content –folder.