Move a Website to a New Server - The Easy Way
Shows you a simple, step-by-step way to move a website with little or no user-generated content from an old web server to a new one.
If you run a website for any length of time, chances are you'll want to move your site and email to a new web server at least once. For example:
Let's assume you've chosen a new Web hosting company and you're ready to transfer your website. Broadly speaking, there are 2 ways that you can move your site across:
In this step-by-step article I'll try to give a general overview of the moving process, and look at some of the pitfalls to avoid along the way. I strongly recommend reading this whole article before you start the moving process.
Here's a brief overview of the steps:
- Back up your site. Make a backup of your site files and data on your own computer.
- Set up your web space and email on the new server. Prepare your server to handle your site and email accounts.
- Upload your site. Upload the backup you made in Step 1 to your new server. Check the site works. Visit your site on the new server and make sure everything works.
- Configure your email software to check mail on both servers. This ensures you don't lose any email messages during the transfer.
- Shut down interactive areas on your old site. This optional step prevents visitors adding any new content to your old site during the changeover.
- Redelegate your domain. This moves control of your domain to the new nameservers, and gets everyone looking at your site on your new server.
- Retest your site and email. Now that the new server is live, check that everything works as it should.
- Shut down your old hosting account. Once you're confident that everything is working properly you can shut down your old web hosting account.
No two hosting setups are the same, so consider these as general guidelines. If in doubt, ask your hosting companies (old and new) for specific advice!
1. Back up your site
Back up all your current site files and data to your own computer now. (In fact it's a good idea to back up your site regularly anyway.) That way, if anything goes wrong, at least you have your own copy of your site.
- If your site just has static HTML pages then backing up is easy: Simply FTP the site's document root folder (usually called
mainwebsite_html) to your PC.
- If you have server-side scripts (such as Perl or PHP) then make sure you back these up too. Often these are in the document root folder along with your regular HTML files; however they might be in another folder (such as
If your site has a database back-end (such as MySQL) then you'll need to back up that data too. There are several ways you can do this. If you have SSH (shell) access to your current server then you can run a command such as:
mysqldump -u username -p --lock-tables database_name > database_name.sql
Then use FTP (or another similar method) to download the
database_name.sql file to your PC.
Alternatively, if you have access to phpMyAdmin (a Web-based MySQL admin tool) then you can back up your MySQL database using the Export tab.
It's a good idea to back up your email too. If you use POP, first download all your latest email. If you use IMAP, sync all your mail accounts to make sure your local copy is up to date. Then close your mail application and make a copy of the folder on your hard drive that contains your email messages. (Some mail apps, such as Outlook and Apple Mail, let you archive your mail to a separate folder.)
2. Set up your web space and mailboxes on the new server
Your new hosting company may have set up your web space and email accounts for you. If not then you'll need to set these up yourself.
The easiest way to set up your web and email is to use the control panel that comes with your hosting account. (Most servers come with some sort of web-based control panel; popular control panels include cPanel and Plesk.)
Make sure you set up email accounts, or email forwarding, for all of the email addresses you currently use.
3. Upload your site to the new server
Now that your web space is set up, you can transfer your website's files to the new server. This process is pretty much the opposite of Step 1:
- For static sites, just upload the site files and folders to the new server's document root folder.
- If you have scripts, you may need to upload these to a different folder. You may also need to set permissions on the script files for them to run correctly, and also update any paths in the script config files to reflect the folder structure on the new server.
If your site is database-driven then you'll need to upload the database backup you created in Step 1, then import the backup into your new database. For example, with MySQL you can run a command such as:
mysql -u username -p database_name < database_name.sql
If you're using phpMyAdmin on the new server then you can import the data file using the Import tab. However, be careful with this approach, because many web servers limit the size of uploaded files, as well as how long PHP scripts can run. If your data file is very large — say, greater than 10MB — then you may run into problems. In this case, use the command-line technique above, or ask your hosting company to import the data for you.
4. Check the site works
You've moved your site to the new server, but it's not yet live (since the DNS hasn't been transferred). Now is a good time to test your site to make sure everything works.
To do this, you need to tell your PC to look at your new server rather than the old one when browsing your site. You can do this temporarily as follows:
- If your PC runs Windows: Edit the file
C:\WINDOWS\system32\drivers\etc\hosts. You can do this by clicking Start, then Run, then typing notepad C:\WINDOWS\system32\drivers\etc\hosts into the Run box, and clicking OK.
- If you run Mac OS X or Linux: Edit the file
/etc/hostsusing your favourite text editor. You'll need root privileges to do this. For example, in Mac OS X, open the Terminal app then type: sudo pico /etc/hosts.
Once you've opened your
hosts file, add the following line to the end of the file:
ip address domain name
where ip address is the IP address of your new server, and domain name is your website's domain name. For example, if you were moving your site
www.example.com to a web server with an IP address of
188.8.131.52, you'd add the line:
If you're not sure of the IP address of your new server, ask your hosting company.
Now save the file and quit the editor. You can test that your change has taken by opening a terminal window (Start > All Programs > Accessories > Command Prompt on Windows) and typing:
If you see your new server's IP address in the output then the change worked.
Now open a browser and enter your website's URL in the address bar. This will display the site on your new server. Visit all areas of your site and check everything works. If you get any server errors then you may need to look in your new server's error logs for details (ask your hosting company for advice). Check for common problems such as incorrect paths, incorrect permissions, and missing files/folders.
Some hosting companies give you an alternate URL to browse your new site before it's "live", such as
www.hostingcompany.com/~mynewsite. This saves you from having to edit your
5. Set up your email program to check mail on both servers
Since it can take a couple of days to change over your domain to point to your new email server, there will be a period when some people are sending email to your old mail server while others are sending email to your new server.
Therefore it's a good idea to get the email application on your computer to check both mail servers for new mail during the transition period. Follow these steps:
- Change the current "mail server" setting from a hostname to an IP address. Open up your email program and find the settings for your current mail server (this will probably be in a "mail accounts" section in the preferences). Chances are that the "mail server" box shows the hostname of your old mail server (e.g.
mail.example.com). Change this to the server's IP address instead (e.g.
184.108.40.206). This ensures that your mail software continues to check the old server, even once the domain has been switched over.
- Add the new mail server. Create a new mail account in your mail software and add the details of the new mail server. Again, use the server's IP address instead of its hostname, so that you know it's checking the right server.
If you're not sure of the IP addresses of your old and new mail servers, ask your old and new hosting companies.
6. Shut down interactive parts of your site (optional)
Once you move your domain (see the next step), it will take up to a few days for everyone to start using the new server. If your site features areas where visitors can interact and add content (forums, blog comments, shopping carts, and so on) then you run the risk of some people adding content on the old site while others add content on the new site. When the domain has finally moved then the new content added to the old site will be lost (unless you manually import it into the new site, or ask your visitors to re-post their content!).
If you only get a blog comment or two a day then you may not care. However, if you'd rather visitors didn't add stuff to the old site during the changeover, you might want to shut down just the areas of your site where users can add new content, such as forums, blog comments, and registration forms, and put up a holding page informing them that these areas will be back soon.
If your site is busy and visitors regularly post lots of content then you may want to move your site the seamless way instead.
7. Redelegate your domain
Redelegating your domain means telling everyone on the internet to use your new hosting company's nameservers when looking up your domain, rather than the old nameservers. Since the new nameservers point to your new web server, this process effectively tells everyone to view your site on the new server.
To redelegate your domain, follow these steps:
- Check your new nameservers. Find out the hostnames of your new nameservers. Usually there are 2 nameservers, and they'll have hostnames along the lines of
ns2.example.com. Your new hosting company will probably have sent you an email with this information. Also you might want to double-check with the hosting company that these nameservers have been properly set up to host your domain. (Usually this happens automatically when the hosting company sets up your web space.)
- Login to your registrar's website. Your registrar is the company you registered your domain name through. It may or may not be the same company that currently hosts your site. Usually the registrar sends you a username and password that you can use to login to their site to update your nameservers.
- Change the nameservers. Find the option to edit/change your domain's nameservers. Change the nameserver entries to the hostnames of your new company's nameservers.
- Wait. Sit back, relax, and wait (usually around 24-48 hours) for the redelegation to propagate around the internet.
Congratulations — your site is now live on your new server!
Once the redelegation has propagated, delete the line you added to your
hosts file in Step 4.
If you're unsure of your domain registrar, you can look it up using a service such as DomainTools' Whois Lookup. Just type your domain name and hit Return; you can then click the Registration tab to see the registrar name.
8. Test everything works
Once your new server is live, check again that all aspects of your site work properly — especially interactive areas of the site, such as contact forms, user registrations, blog comments, and forums.
It's also a good idea to send various test emails from and to your email accounts, as well as from and to external addresses, such as Yahoo! Mail or Gmail. If an email bounces, take a look at the headers of the bounce message to identify the problem. (If you can't work out what's wrong then forward the bounce message to your hosting company for investigation.)
Moving IMAP folders
If you use IMAP instead of POP then you'll want to copy across all your email messages and folders from your old mail server to the new one. To do this, open your mail application on your computer, then:
- Select the "Synchronize Account" option (or similar) for both the old and the new accounts to ensure that your mail program is in sync with both servers.
- Drag your mail folders from the old account to the new.
Bear in mind that it can take several hours, or even days, to sync the changes up to the new server, especially if you have lots of messages and a slow internet connection. You can speed up the process by copying across your IMAP mailboxes directly from the old server to the new one using, for example,
rsync. Be careful not to overwrite any new messages that have arrived at the new server. (Your hosting company may be able to do this for you).
9. After a few days, shut down the old hosting account
Once a few days have passed, chances are good that everyone will be using your new server rather than the old. You can double-check this by inspecting your site access log and email log on the old server (if you have access to them). You might still see the odd search engine crawler visiting the old site for a time, and the odd spammer sending mail to your old email server. On the whole, though, you should see very little, if any, activity.
You can now safely shut down the old hosting account or server. You'll also want to open your email program and remove the mail account for your old mail server, and change the new mail server's IP address back to its hostname.
If all has gone well then you've now successfully moved your site and email from your old hosting company to your new one. Well done!
Responses to this article
5 responses (oldest first):
firstly, export the MySql file from your phpmyadmin. Inorder to know, how to do it:
Simply log into phpmyadmin, click on EXPORT, default is SQL radio button, which is good, now click the "save-file-as" box, and then you are done.
upload all the files to desired folder and upload the sql file into new database. (it can be done by just logging into phpmyadmin and using import button.)
Now, change the db_username, db_password and db_name to the current db details.. and you are done!!
Your cms site is now up and running from a new server...!!
Any questions please, reply back!!
well, when uploading/importing the database, I'd go with your suggestion of command line method..
Its an overall best way to do any thing via command-line/terminal.
will start writing posts on wordpress and will also upload the templates I've designed, so elated-scribers can use it..!!
For best [url=https://www.mapitinc.com/professional-website-design.php]professional website design[/url] services for only $1/ month. Feel free to visit us or
Call at toll free: 1-800-929-6163 and place your order now.
Address: 207 Mineola Ave., Suite 515 Roslyn Heights, New York 11577
Questions regarding sales: email@example.com
After sale support: firstname.lastname@example.org
[Edited by jasonelve on 19-Jul-14 05:52]
Post a response
Want to add a comment, or ask a question about this article? Post a response.
To post responses you need to be a member. Not a member yet? Signing up is free, easy and only takes a minute. Sign up now.