Steps to install WordPress on Azure Virtual Machine running Ubuntu

I have moved my blog to Azure Website for a while and I am quite happy with it. However, recently I have decided to move my blog to an Azure VM running Ubuntu.

I have to say Azure Website is very fast, convenient and easy to set up: you just have to create a new website, chose the WordPress template and go though the WordPress’s 5-minute setup. However, that require you to scale up to Shared, Basic or Standard plan (which cost at least 10 USD/month) to get some more advanced features such as setting custom domains. Besides, the free MySQL database by ClearDB provides you with only 20MB, and the cheapest upgrade is another 9 USD/month for 1GB (quite huge for my blog).

Recently, I happened to create a Ubuntu VM for my research. And most of the time the VM is idle. So instead of turning it on an shutting it down all the time to save cost, I decided to move my blog again to the VM, and buy a new domain for it:

However, setting WordPress up on a Virtual Machine with Ubuntu 14.04 is not really as joyful as on an Azure Website. It cost me almost 3 days to solve all the issues, so I decided to note down all the steps I take here in case I need to move my blog again in the future, or someone else gets the same problems.

Setting Up LAMP (Linux-Apache-MySQL-phpMyAdmin)

To setup Linux, I just choose a Ubuntu images when creating the VM. No hitch here.

Setting up Apache, MySQL and phpMyAdmin is as simple as running

Enable phpMyAdmin (so that it can be accessed via by adding the following line to etc/apache2/apache2.conf

Setting Up WordPress

Again, we can use apt-get here

Most of the blog engine will be installed at /usr/share/wordpress and some common contents are put at /var/lib/wordpress.

You can copy the content inside /usr/share/wordpress into Apache web directory /var/www/html. However, I believe it is better to create a symbolic link inside the html folder.

This will allow your user to visit your blog by going to

Change the owner of the WordPress directory to Apache user and group (you can check APACHE_RUN_USER and APACHE_RUN_GROUP in /etc/apache2/envvars) to enable uploading files, installing themes and plugins:

Copy the sample configuration file to create configuration for your domain

Add a new user and database to your MySQL server using phpMyAdmin

Modify accordingly

Go to to see more or go directly to to continue with the installation steps.

Change Apache config to allow visiting directly at

Currently I do not have a website yet. So or are too complicated; featuring the blog directly at is better for now. And this can be done by some simple Apache configuration changes.

Duplicate default site config:

Change the blog.conf:

Disable the default site and enable the new blog site:

Change WordPress and Apache configurations to enable Permalink

Enable mod_rewrite in Apache

Enable Permalink in WordPress dashboard

Enable rewrite rules in .htaccess file in WordPress main directory:

Set Overrides All (to enable rewrite rules inside .htaccess file)

Migrate blog contents

Last time when moving my blog to Azure Website, I migrated my blog’s contents by duplicating the database and copying all the files using FTP. That turned out to be not so efficient for me because all the images pointing to the old domain (will not be a problem if you are using CDN of keeping the old domain and URL structures).

This time I happened to learn that WordPress already has a built-in import/export function. Using that function is also very simple, and you can easily modify the exported XML file before importing. Images and attachments can also be imported automatically.

Installing Plugins & Reconfigure Settings

Unfortunately, those things will not come with the built-in import/export tool. It cost me some time manually reinstall all WordPress plugins and reconfigure all the settings. However, if you do not move your sites very frequently, maybe it is a good time to review all your plugins and configurations.


So my blog is now officially move to (much better than last time). I will start working on redirecting all the traffic from the old site to the new site, and that will probably have a separate blog post.

Some interesting read

2 thoughts to “Steps to install WordPress on Azure Virtual Machine running Ubuntu”

  1. Hello,
    Nice post!.
    Can you tell me how did you point your new domain to your Apache on the new vm on Azure, I mean DNS part setup?
    Thank you,

    1. The specific steps depend on the DNS service you are using. Normally I would add a CNAME record pointing to the VM domain.

      I usually have 2 records like below

      • Host name: @. IP/URL: Type: URL Redirect
      • Host name: www. IP/URL: Type: CNAME

      The URL in the second record is the domain of your VM provided by Azure. For classic VM, you will get something like, and for newer VM with Resource Manager stack, the domain will be like You can check the exact domain of your VM in the Azure portal.
      This setup allows and to point to my VM.

      You may also want to replace that 2 records by an A (address) record instead, so that any subdomains can point to the same VM.

      • Host name: @. IP/URL: Type: A (address) is the public IP address of your VM (can also be seen in the Azure portal). However, make sure that you have already purchased a static public IP address in Azure, or your domain will point to the wrong place once your VM’s public IP address changes.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.