Kamloops Website Design, Kamloops Website Development and Kamloops Website Hosting - Adroit Technologies (ATWS)

 

How to Migrate your Website

 

Welcome to our guide about how to migrate your website! This guide is a three five part series describing some high level techniques that are common to website and server migrations. To begin, we will describe the topics that will be covered along with the required environment setup.

What's Going On?

If you are transitioning from an old design to a new design, changing Content Management Systems (CMS) or transferring to a new server, there are several steps that must be carefully executed. For Adroit Technologies, we finished migrating our website to a new design and CMS. We decided to start to a guide to help people who may be confronted with a migration process and to present some issues that people may encounter.

This guide was not designed to be a fully inclusive howto but rather a high level reminder of, "Oh yeah!" to help guide you as to what may be required while you do your transition. So let's begin with what we will cover:

Whats Covered in this Guide

Whats Not Covered in this Guide

Environment & Software

First Things First - Backups!

As always, before you do anything, CREATE BACKUPS. Seriously though. If you didn't create backups and something goes wrong, it is always going to be your fault. This is your last warning, create backups please.

Now with that in mind, these are some areas to consider backing up:

  1. Your current site to either your computer or to a different directory on the server
  2. Any databases and or support files

Also, don't forget to do the following:

  1. Upload your new website/CMS/etc... to a different folder; don't overwrite your current one!
  2. Upload all files required for the new website (database, html, images, etc) into an SVN, CVS or GIT repository (if available)
  3. Setup any databases and other support files you might need.

Test your new site without taking down your old one!

Since your current website is live, we don't want to cause any sort of service interruption that may occur when we upload our new website. We ran into a small issue where we needed to change a configuration path. If we would have over-written our live site with our new site, customers would have noticed the error page.

A simple and easy method to avoid such issues from occurring is to upload the new site into a separate directory and create a simple host file entry. This is a method to test your new website without taking down your old site, while still keeping it semi-hidden from the outside world and while avoiding the setup of new DNS entries to test the site.

Hostname resolution using the hosts file

To resolve domain names, an operating system uses a few different methods to convert a domain name to its associated IP address. For a basic high level understanding, the process to resolve a domain name is as follows: the operating system first checks its local resolution/cache and then the DNS server that was configured either through DHCP or manually. We are interested in the first option, the local resolution/cache. This is usually implemented through a basic table saved in a file. For Windows XP, this file exists in [Windows Install Directory]\system32\drivers\etc\hosts and for Linux, this will is located in /etc/hosts.

We will edit this file to create a simple "pointer" to our new website without having to modify and update a DNS server. Using this method relies on a virtual host entry in Apache which will be discussed shortly.

  1. Open up Notepad, or Notepad++, or gEdit, or Nano
    1. If you are running Windows Vista or Windows 7, you will need to run these programs as an Administrator
    2. Winth Linux (and Mac), you will need to sudo/gksudo the editor in order to save the changes
  2. Open up your hosts file
    1. For Windows, this is located in: [Windows Install Directory]\system32\drivers\etc\hosts Windows Host File
    2. For Linux, this is located in: /etc/hosts
  3. Enter a new line into your hosts
    1. You would enter your web server IP address in place of the 192.168.1.1 address
      192.168.1.1     new.website-url.com
    2. To get your IP Address of the server on Windows.
      Start > Run > cmd 
      ping atws.ca  
      
    3. To get your IP on linux:
      host atws.ca

Now that we have a "domain" that points to our new site, we need to setup an Apache vhost (virtual host) entry.

Setup a new Apache vhosts entry

A virtual host (vhost) allows for a system administrator to serve multiple websites from a single computer on a single IP Address. Typical uses of vhosts are found on shared web hosting. Vhosts rely on the user's browser sending the address that the user typed in to the browser in the Host option of the HTTP header. This allows the server to distinguish which website to serve to the user.

With this brief introduction in mind, let's add some virtual hosts to the vhosts file of Apache

  1. Login to the webserver using a terminal client program. PuTTY is a good Windows client for SSH access.
  2. Backup the current vhosts file(s) for your website(s)
    1. Typical virtual host entries location:
      /etc/apache2/sites-available/
    2. Example:
      sudo cp ./vhosts ./vhosts.June.17.2010
  3. Edit the current website file and add a new virtual hosts entry
    • Example virtual host entry:
      <VirtualHost 192.168.1.1>
      ServerName new.yourdomain.com
      DocumentRoot /path/to/your/new/website/directory
      DirectoryIndex index.php
      </VirtualHost>
      
    • This virtual hosts entry is very simple and is used as an example; you may have to add additional parameters for your website setup (use your old virtual host entry as an example.)
    • More information about virtual hosts configuration
  4. Enable the virtual host file in Apache. This only needs to be done if a new virtual host file was created in sites-available
    sudo a2ensite new.yourdomain.com
  5. Reload Apache for the virtual host file to take effect
    sudo apache2ctl reload
  6. Try to access the website using the virtual host entry along with the new hosts entry Firefox vhost Example

Conclusion

With the above steps, we have backed up our site and support files, setup a temporary hosts entry and created a vhost entry for Apache. This provides a quick and effective method for site migration with minimal down time. We have also learned about vhosts, domain name resolution and hosts files.

If you have any comments, questions or additions, please comment below!

Next...

Look forward later this week for part two of the Site Migration Series where we will discuss traffic and and website monitoring along with system administration techniques to ease this process.

Recent Entries

Site Migration Series (3 of 5)
How to Migrate your Website

Site Migration Series (2 of 5)
How to Migrate your Website

Site Migration Series (1 of 5)
How to Migrate your Website

Use Google Page Speed to speedtest your website.
Use Google Page Speed to check the speed of your website, focusing on DNS and other common issues

ModX Ditto RSS - Wrong Copyright Year
How to correct the copyright year in ModX's Ditto RSS Feed Builder

Archives

 

Recent Work

View our work portfolio

Learn about us

Discover Adroit Technologies

Our Services

Services matching your needs

Read our blog

Follow our latest news