Microsoft makes WordPress on Azure easier, but a tricky situation arises when we need to use MsSQL instead of MySQL for WordPress on Azure. I recently did a project that we migrated a website where wordpress connected to MySQL DB to WordPress, then connected to MsSQL DB. I made many mistakes and encountered many issues so I would like to share them here in hopes you will spared some headaches.
- PHP extension sqlsrv driver installed (read this post http://docs.gurock.com/testrail-admin/howto-installing-sqlsrv)
- PHP (Only if you wish to run it on IIS)
- PHP Manager on IIS installed (Only if you wish to run it on IIS)
- SQL Server (On Azure, you need a SQL Azure)
WordPress connecting to MsSQL on IIS
To deploy WordPress on IIS, you need to:
- Install Microsoft SQL Management studio
- Install PHP on server
- Enable SQLSRV extension in PHP (read this post http://docs.gurock.com/testrail-admin/howto-installing-sqlsrv)
- Download WordPress at HERE. You can also do it via WebMatrix, but I recommend you download WordPress manually
- Create a website on IIS and making the application pool “No Managed Code”
- Before running the WordPress site, install WP-DB-Abstraction Plugin as MU-Plugin
- Run and Install WordPress on the site
- Follow the instruction and step 2 of the installation process, choose SQL server by using Microsft PHP driver -sqlsrv
- Done! Your site is running on MsSQL now!
Problems / Errors that I encounter during setup for WP-DB-Abstraction
- web-config.php exists (This is very important. Make sure it’s a pure copy or delete it)
- web-config-sample.php is missing
- Make sure your IIS can run PHP code
- Install SQLSRV extension on php. If this is not installed, the “SQL Server using Microsoft PHP Driver” option will not show up at the dropdown box during installation
WordPress connection to SQL Azure
Now, we are ready to move the site to Azure
- Create a website on Azure. Upload an uninstalled copy of WordPress with WP-DB-Abstraction Plugin in place. Refer to the Section “WordPress connecting to MsSQL on IIS”
- Create a SQL Azure database
- Manage your website via Azure Portal, Go to Website -> Configuaration
- Under the App Setting Section, put in “PHP_EXTENSIONS” as the Key and your “php_sqlsrv.DLL” is located at VALUE. For me, I uploaded a folder called EXT in the root via FTP, so my key is “EXT/php_sqlsrv.DLL”
- Finishing the WordPress Installation
- Voila, everything should be working.
If you have any questions or comments, please email me at firstname.lastname@example.org. Follow our up-coming blogs next week. Have a nice weekend!
By Michael Siu