Install & setup WordPress on Microsoft Azure

This post will include a lot of terminal commands, so please try to follow the tutorial step by step and try not to skip any step.

Setting up your server

Step 1: To communicate with your virtual machine, you need to establish an SSH connection and use an SSH client.

What is SSH?

We are using PuTTY, a free SSH and telnet client in this tutorial. So for this step, you are required to download and install PuTTY from here. Step 2: Login to your Azure panel, open the virtual machine, we created in the first part and hit ‘Start’. Then click on ‘Connect’ to start the connection. Now a pop-up will display your username and the public IP address of your machine. Copy the entire SSH hostname (e.g. [email protected]). You may click on the images to see the larger version.

Now open PuTTY and paste this hostname in the Host Name field and select connection type as SSH and hit open with all other settings as default. A new terminal window would open and will prompt you for the password. Enter the password that was chosen in part 1 while creating a virtual machine. Now you are finally connected to your virtual server over an SSH connection. All you need to do now is enter some commands in this terminal window to install proper software and WordPress.

Installing Apache

Step 3: First of all, you need to make sure that all the packages on your installation of Ubuntu are up to date. Run the following command to update them: Now we’ll install Apache, a free HTTP server software. Basically, Apache will be the one listening to someone’s request to display your website’s content. Read more about Apache here. Run the following command to install Apache: Now navigate to the directory where Apache’s configuration file is saved and open it using the text editor. At the end of this file add the following line: Now save the file by pressing ‘Ctrl + O’ then Enter and then ‘Ctrl + X’. Restart the Apache service: And grant permissions to Apache by executing the following command:

Installing MySQL and PHP

Step 4: Execute the following commands in order to install MySQL and PHP on Ubuntu: Choose an appropriate MySQL root password and hit ‘Enter’.

PHP files are to be given more priority than the HTML files, so we need to alter another configuration file: Now in this file, move “index.php” so that it comes before “index.html”. Restart the Apache server.

Creating a MySQL database

Step 5: Follow the commands: These commands will create a database named test with a user called “tester” and password “testpwd”. This database will be used by WordPress to store all the data.

Installing WordPress

Step 6: This is actually the step that downloads WordPress. Navigate to the root directory and then download and extract WordPress. Navigate to the WWW directory where all the website files are stored and copy the entire contents of the WordPress here in a new folder of your choice. Now create the wp-config.php file by creating the copy of sample configuration file and then copy the entire contents of the downloaded folder into the ‘wordpress’ folder in the www directory. Navigate to the new website directory and edit the WordPress configuration file so that the WordPress can communicate with the database. Enter the database details we created in previous steps and save the file. (see screenshot below for reference)

Configuring Apache

Step 7: Now for the final step, we need to configure apache so that it knows there is a website running under our “twcwp” folder. We need to navigate to the available sites folder and create a new file called ‘twcwp.conf’ which is similar to the default configuration file. In this file alter the following lines

ServerAdmin your_email_adressServerName twcwp.comServerAlias twcwp.comDocumentRoot /var/www/twcwp

ServerAlias should be the domain name you’ve registered (in our case we’ve not registered the domain name but we are just using it for reference). Execute these final set of commands: Here “twctestingadmin” is the username of admin account on our virtual machine and “twcwp” is the directory that contains WordPress files. You can replace these strings with your details. And this is it, now you have a fully functional virtual machine running on Microsoft Azure that is hosting your WordPress website. All you need to do is now configure your DNS records so that the website points to the public IP address of the virtual machine.

If you want to temporarily run your website, you can edit the Windows hosts file and add an entry that will map the public IP address to the domain name temporarily. (see screenshot for reference)

The tutorial is pretty long and involves a lot of steps. You may feel free to ask any questions in the comments section below and we will be happy to help you out. Some terms used in this post may seem new to you, you can Google search them or just drop a message in comments. Also, I would like to introduce you to the two personalities who brought us this wonderful Workshop in the Chandigarh area:

Jasjit ChopraDivyadeep Sawhney

The workshop was collectively conducted by Microsoft Users Group Chandigarh and WordPress Chandigarh. You can get in touch with both the groups on Facebook and look for upcoming meetups in Chandigarh area on meetup.com.

How do I create a WordPress site on Azure?

To create a WordPress site on Azure, you need to follow the aforementioned guide. The summary of the process is like any other setup process. In other words, you need to create a server, upload your files, and set things up as per your requirements. However, it is recommended to follow all the above-mentioned steps minutely to get things done without any error.

Can I host WordPress on Azure for free?

No, you cannot host a WordPress site on Azure for free. However, Azure offers a free trial that you can use to test your site. Following that, you need to opt for paid plans to get started with the project. Related reads:

How to install WordPress on Google Cloud PlatformHow to host WordPress blog with Microsoft IISCreate WordPress site using Microsoft WebMatrixHow to install WordPress on Windows PC.