how to migrate a website without breaking access for final users

Here is a short tutorial and a useful tip when you plan to migrate a website from a server to another (production servers), in order to avoid to have an interruption during migration:

The process

  • Setup the new server (apache, mysql, etc…)
  • Dump the database, copy files of the websites from the old server to the new one
  • Finalize the setup

When the migration of the website is done, find below how you can test the website with the definitive domain without changing immediately DNS configuration: you can bypass DNS server from your computer. To do so, just add some lines to your file /etc/hosts:

# vim /etc/hosts

And save it.

Then you will be able to test locally from your laptop your new website with the real definitive domain.
Other users from the internet will still be directed to the old server as DNS change is not done.
When you checked locally that everything was OK, then you can delete the line in your /etc/hosts and modify the DNS configuration.
When propagation will be done (wait 48 hours at least), then you can deactivate the old server.

GD Star Rating