Hosting single site WordPress in Azure is straight forward. With few clicks in Azure portal, your blog will be up and running easily. While moving my blog to Azure I face issues but managed to resolve it. So let see the issues:
This is one of the most nightmare that every blogger tried to avoid, the slowness. The default settings provided by the template doesn’t provide optimum performance. I use GTmetrix (https://gtmetrix.com) , WebPagetest (https://www.webpagetest.org) , and Pingdom (https://tools.pingdom.com). The tools just reported that the page is too slow and unable to continue.
Error 500 / timeout, while importing WordPress XML
WordPress has good export/import tools, to allow blogger export the post from old location, to new hosting. While exporting, usually we won’t get any issue. It can create XML file (exported as XML) bigger than 5MB in my case. However, the tools suggest that it only allows import maximum 1 MB. I use WordPress WXR File Splitter – to split into 500KB each, but I always got error 500 / timeout every time I tried to import the blog.
(image: maximum 1 MB)
Broken Link Multisite File handler
In my original WordPress hosting, all media files (images/video, etc) will be served from /files/[siteid]/[yyyy]/[mm]/[imagefilename.jpg]. This location then will be rewritten by .htaccess and served from different location based on site’s upload folder. The site is indicated by siteid, which is the site id in the multisite setting. Although I browse the images using developer tools, in the Azure App – its always return 404 in the browser. So all images gone.
Change Application Settings
Thanks to the google, this is changes in environment that I have done. Don’t ask me why, just google it! But believe me, I spent days to find it – these settings is just to help saving your time.
- Click Application Settings
- Add “PHP_INI_SCAN_DIR” , value “D:\home\site”
- Add “WEBSITE_LOCAL_CACHE_OPTION” , value “Always”
- Enable Always On
Dot user dot ini file, is used to override some of php.ini settings. Since the php.ini settings is read only in App Service, then we create .user.ini and configure the settings in this file. Create .user.ini file and enter following content
Translate missing .htaccess rule to web.config rewrite rules
In my case, I translate redirect rules which is applied to /files/* , into web.config rewrite rules. I added this rules, on top of the WordPress multisite web.config default rewrite rules.
Modify wp-includes/ms-files.php for handle missing environment variable
I think this might not applicable if you have “BLOGUPLOADDIR” variable configured properly. Since I am too lazy to find how to add this variable (may be from settings??) – I decided just to add my own logic in it. I just add second try, with my $file_patch variable.
Use AutoOptimize Plugin
Using optimizer still not giving me the target page load below 1s. Initially I was thinking to use Azure, MaxCDN but all of those service are paid service. Azure CDN is one of the best, but the integration is not simpler – and its paid service per GB traffic. So, I decided to use CloudFlare free plan – and for my blog I don’t need the pay as you go plan. The CloudFlare is easy to setup, just by putting their NS as our domain NS – then all traffic will be routed via CloudFlare CDN. It also provides SSLOffloading on their end. So my blog is now SSL enabled with this free plan.
After all of these process, now my blog is hosted in Azure with the smallest shared plan and good page response time. My latest validation the page response time is 500 – 1200ms.