Installing WordPress Multisite on Azure
Over the weekend, I migrated all of my WordPress sites to Azure websites. I had three main goals:
- Simplify the underlying technology stack
- Centralize site management
- Optimize security and performance
- Thanks to WordPress Multisite, Project Nami, Azure, and CloudFlare, mission accomplished!
About WordPress Multisite
When I started with WordPress, I had to create Apache bindings and individual MySQL databases for each site. Every time I set up a new website, I had to reacquaint myself with the process of installing WordPress. Plugins, themes, etc. had to managed independently.
WordPress Multisite was introduced in version 3.0, allowing for multiple WordPress sites to be managed within one installation. That means one HTTP(S) binding, one database, and unified upgrades.
I have to say, this works even better than I hoped. It’s not only easier to manage code assets; it also allows you to share posts and media easily across sites in “network”. I haven’t found any downsides yet.
About Project Nami
Project Nami is the other key that’s made my website management easier. Although I’ve been working with Linux on and off since the ’90s, I spend most of my time in Windows, so LAMP management always took longer than I’d like. And I know that WordPress with PHP and MySQL on Windows is possible, but it’s always seemed like an uphill battle.
Thanks to the generosity of project creators Spencer and Patrick (no surnames – apparently they’re not in it for the fame), Project Nami adapts all of the database logic in WordPress to work with Azure SQL, which is no small feat. That removes all dependencies on MySQL. It’s available as a ZIP archive containing all WordPress files patched to work with Azure SQL. They’re very fast with updates. When WordPress rushed out version 4.2.1 with security updates, Project Nami was updated within a day.
It’s worth noting that there are MySQL hosting options in Azure. The most popular is a third-party offering from ClearDB, which is available as a PaaS linked resource. It’s a decent option, but not as affordable or as well integrated as Azure SQL. For simplicity, I preferred to stay with the Microsoft stack.
Azure needs the least introduction. In short, we use its Azure websites, Azure SQL, and storage features (to manage backups).
CloudFlare is an amazing content delivery network. By routing all of your traffic through it, they “supercharge” your site with the following free benefits:
- DNS (including CNAME flattening)
- Content delivery and caching
- Flexible SSL with SNI
- Firewall and preprocessing rules
- Traffic analytics
Using CloudFlare, I’ve been able to add SSL to each site, use “page rules” to enforce HTTPS, and improve performance through aggressive caching.
Guide: WordPress Multisite on Azure
Here are the main steps I took:
- Deploy Azure SQL database i. Set up Azure website with PHP enabled
- Add Azure SQL database connection string to simplify backups
- Install Project Nami to Azure website
- Run the famous WordPress 5-minute install i. Enable multisite with the “WP_ALLOW_MULTISITE” ii. Set up the seven web.config rewrite rules on this page
- Create a network i. Install WordPress MU Domain Mapping plugin
- Create each site and map domains for each
- Export each site’s contents under “Tools” > “Export”, then import using “Tools” > “Import” i. You may need up increase the “upload_max_filesize” and “post_max_size” settings using a “.user.ini” file ii. Even with larger upload limits, you may need to run the import multiple times, especially if you have a lot of media
- Test everything on the new site
- Move DNS i. In CloudFlare, create awverify CNAME records matching the domain ii. In Azure, add the domains iii. In CloudFlare, create CNAME records pointing at your *.azurewebsites.net URL
- Once everything’s working, back up the website and database through the Azure portal i. Optionally, enable daily backups with 30 days retention
Those are the main steps I took. Again, I’m really happy with the results. Each site is now faster, encrypted, more reliable, and easier to manage.