Move WordPress to a new IIS 8.5 Server

WordPress has become the defacto standard for blogging software with applications that extend beyond that.  Now with Web Platform Installer (WPI) working so well and being so seamless in IIS 7 and above, WordPress can easily be installed and run on modern Windows servers.  Due to the ease of installation, management, upgradability, and flexibility, I myself have moved most of my sites over to this platform.

Eventually you may find the need to move your WordPress site to another server.  This is where it can start to become muddy.  Hopefully I can help you make it as painless as possible using the Duplicator Plugin.  You should be live on your new server before you know it.

Reduce your domain name Time to Live (TTL)

To make moving and testing your site easier, the first step you should take is to change the TTL of your domain name at the authoritative DNS servers to 5 minutes.  By default, most DNS servers have this set to 1 hour, telling other Internet name servers how often they should check for new records.

Set Permalinks to Default

Most WordPress migration documents recommend that you go to Settings -> Permalinks and set them to default before migrating a WordPress site.

Install the Duplicator Plugin

On your WordPress site, use your dashboard menu to select Plugins -> Add New.  Search for Duplicator.  Once you find it, click Install Now.  Once it has been installed, make sure you activate it.

Backup Your Site With Duplicator

While in the dashboard for your site, select Duplicator from the left menu.  Click Create New which will create backups of your WordPress directory tree and database.  Click next, and Duplicator will scan your system and let you know if any adjustments need made.  When it is all good, click Build.  When it is finished, click Installer to download a copy.  Then click Archive.  These files are a backup of your site so it is good to keep a copy of them.

Create a New Site

On the new IIS server, open up IIS Manager.  Right click on Sites and Add Web Site From Gallery.  This will open up WPI from within IIS Manager.  Search for WordPress, then go through the steps to create a new site and MySQL database.  At the end of the wizard, make note of the database and user that were automatically created so that you can delete them later.

Open up your hosts file at C:\Windows\System32\drivers\etc with notepad and add an entry for your new IP address and your domain name.  Save the file but don’t close it yet.  If you ping the domain name, you should see that it is resolving to the new IP address.  Open up the site in a browser to test.  You should find that an initial installation of WordPress has been completed and it is ready to configure.

Go to the root folder of the new site and delete everything from there.  Upload the zip file and installer.php that were created from Duplicator and put them in the root of your site.  Next, unzip the zip file into the root of the site.  Duplicator can do it but it’s not designed for a Windows server so best to do it yourself from my experience.

Create Your MySQL Database and User

Next you need to create your database to match what was on the old site.  If you look at the wp-config.php file in the root of your live site, it will have the DB_NAME, DB_USER, and DB_PASSWORD listed.  Make note of that information and use it to run from a command prompt, substituting the above information where necessary

MySQL -uroot -pROOT_PASSWORD
MySQL> create database DB_NAME;
MySQL> grant all privileges on DB_NAME.* TO “DB_USER”@”localhost” identified by “DB_PASSWORD”;
MySQL> flush privileges;
MySQL> exit;

Adjust Permissions

Duplicator will require additional permissions on your site.  To make sure everything works properly, set the NTFS permissions for your site so that everyone has write permissions.  This is only temporary and we will remove this after the migration.

Run the Duplicator Installer

In your browser, go to your site, http://yoursite.com/installer.php.  This will bring up the Duplicator installer.  Step through the installation process.

Step 1:

  • Keep Create New as the Action
  • Enter your MySQL Database Name, User, and Password from above
  • Test Connection to make sure you have the information correct.
  • Go on to Step 2

Step 2:

  • Keep the URL the same
  • Select Advanced Options and select the manual unzip process
  • Finish

Review the results from Step 3.  If you open up a new tab, you should be able to test your site and see that it is working properly.  Going back to the dashboard for the site, you will see that Duplicator is letting you know that there are files that need cleaned up.  Let it go ahead and delete the installer* files.  You will also want to delete the .zip file from the root of your site.

Update DNS

Assuming everything is working as expected, update DNS to point to the new IP address.  Since your TTL is 5 minutes, this should only take about five minutes to complete.  Once it is good, set the TTL back to 1 hour.

Update Hosts File

Go back to your hosts file and either remove the line that you added or precede it with a #.  That will comment out the line.  Save and close it.

Enable Permalinks

Set Permalinks back to what they were at the old location and test that they are working as expected.

Adjust Permissions

Remove the everyone user with write permissions.

Remove MySQL Database

Remove the MySQL Database that was created by the Web Platform Installer.

Cleanup your old server

After verifying that everything is all good, cleanup your site on the former live server.

I would like to give a shout out to Jeff Reifman for his post on Moving Your WordPress Site.  His process was the best that I came across (with great pictures) and I used it as the inspiration for this post.  Once I ran through it, I saw the differences between running WordPress on a Linux server versus a Windows server and wanted to have the migration process on Windows servers documented also.