Over a million developers have joined DZone.

Installing WordPress Website in a Subfolder on Your Azure Website

· Java Zone

Discover how powerful static code analysis and ergonomic design make development not only productive but also an enjoyable experience, brought to you in partnership with JetBrains

This blog post shows you how to install a Wordpress website in a sub-folder on your Azure website. Now somebody would ask why would I need to do that, and that is a good question, so let me start with the reasons:

Why do it this way?

Assume that you have a website and you want to create a blog section. This is a very common practice and most companies nowadays have a blog section of the website (which replaces the old “news” page). To do that, we would need to either develop a section of our website for blogging, or use a standard blogging engine -something like Wordpress-. Let’s say we agreed to use Wordpress as it is quick and easy and it is becoming the DE-facto engine for blogging. So how do we install it?
Well we could have a sub-domain. Say my website is hasaltaiar.com.au, I could create a sub-domain call it blog.hasaltaiar.com.au, and point this sub-domain to a Wordpress website. This would work and it is good. However, it is not the best option, ask me why. Did you ask? never-mind I will answer :). Google and other search engines split the domain authority when requests come into sub-domains. This means that in maintain a better ranking and higher domain authority it is advised that you have your blog as a sub-module of your app rather than a sub-domain. And this is why we are talking about having the Wordpress blog installed in a sub-folder.

The Database

To install a Wordpress website, we need a MySql database. Azure gives you ONE free MySql database. You could create it from Azure store (Marketplace). There is a good tutorial on how to do that here. If you have exhausted your quota and have already created a MySql db before, you could either pay for a new database with Azure marketplace, or get a free one outside of Azure. I had this issue when I was creating this blog, as we had used the ONE free MySql database for another website, so I went to ClearDb website and created a new free account with a free MySql Database. This is the same provider for the MySql databases on Azure Marketplace, so you would get a similar service and free. One way or another, we will assume that you have a MySql database for this website. Have the connection details to this MySql database handy as we will need them later for installation.

Changes to Azure Website Configuration

In order to be able to install a Wordpress website, you need to make two small changes to your azure website. These are:

1. You need to enable IIS to run php. Azure websites support multiple languages out-of-the-box, you just need to enable the languages that you need. By default, it is configured to run .NET 4.5, you could enable any other languages that you would need like Java, Php, Python, etc. We need to enable Php 5.4 or 5.5 as in the screenshot below.

Azure Website Supported Runtime configuration
Azure Website Supported Runtime configuration

2. We also need to ensure that our Azure website has a list (or at least one doc) for the default document type(s). This is also part of the configuration of your Azure website and it tells IIS what type of document to look for when a user navigate to any path/folder. You could have anything in this list (as long as they are valid docs) and in any order you want them. The important line for us in this case is the index.php, which is the default page for Wordpress websites.

Azure website default document list
Azure website default document list

Wordpress Install

You need to download the latest version of Wordpress from Wordpress.org. At the time of writing this blog post, the latest version is 4.0.1. Once you have the files downloaded, you could change the folder name to be blog and upload it directly to your website. This means that you would have this folder under your azure website /your-website/blog. The files could sit under your wwwroot folder as in the screenshot below.

Azure Website Files hierarchy
Azure Website Files hierarchy

When the file upload completes, we can navigate to the your-website-root/blog/wp-admin. This will start the Wordpress website. Wordpress engine will detect that this is the first time it runs, and it will prompt you with the installation wizard. The installation wizard is very simple, only few steps to set the website title, url, language, etc. The main step is adding the database details. These details can be obtained from the database that you created in the earlier step above. Just copy the database connection details here and you should be set. After adding the connection details, you will see a webpage saying the installation is complete and it would ask you to login (with your newly created credentials) to customise your blog.

That’s it, simple and easy. The method shown above could save you from having to maintain two different websites and would give you the flexibility of having your own, self-hosted Wordpress site. I hope you find this useful and I would love to hear your thoughts and feedback.

Learn more about Kotlin, a new programming language designed to solve problems that software developers face every day brought to you in partnership with JetBrains.

Topics:

Published at DZone with permission of Has Altaiar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}