WordPress with SQL Azure
Join the DZone community and get the full member experience.Join For Free
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 is wp 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.php file 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.
Published at DZone with permission of Mikael Koskinen, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.