In this guide, we’ll look at moving a MYSQL based website to a new server. For the purpose of this guide, this step-by-step is for a vBulletin based site, but the principles are the same no matter what type of application your site is using (eg Drupal, WordPress, etc).
- Transfer our website files from the old server to the new server
- Make a copy of our database
- Transfer the database to the new server
- Set the database up to work on the new server
- Press the on switch!
You’ll need SSH and FTP access to your server (although SFTP is recommended over FTP – and we’ll also offer an alternative of transferring via SCP). I’ll assume you’ve already created a new account on the new server – so that it’s ready to take your domain when you are ready to make the switch… if not go ahead and do that now and come back. Also, before starting, make a back up of your site (database and files) in your usual way!
1) Switching your site off
In your vB Admin Control Panel (ACP)
- vBulletin Options > Turn Your vBulletin On and Off
- Forum Active > Click on: NO
- Enter a reason for turning off
- Then click on Save
If you’re not using vB, or want to turn the site off completely, ignore the above and instead look at step three in another guide I did; Ultimate MYSQL backup script. I actually recommend you use that instead, as it’ll be easier to distinguish the new and old site whilst you are waiting for the new DNS settings for your domain to propagate (just don’t upload backsoon.php or the ‘closed’ htaccess file to your new server – you’ll know what I mean when you take a look at it).
2) Making a copy of your database
Log in to your server via SSH, and type the following:
Replace databaseuser with the Username for that database
Replace databasename with the Database Name
Replace /path/to/backupname.sql with the path that you wish to save your back up to (and make a note of it).
You will be asked for a password. Type it in and press Enter. Your database will be backed up.
(Incidentally this is also a good way to make backups of your database – always remember to turn the site of first though.)
3) Copying your files to the new server
- SFTP to your site and copy all your files from your current site to your PC.
- SFTP to your new server and copy all your site files to the appropriate account
- Do the same for database copy you made in step two
HINT: make sure your sftp program is set to copy ‘hidden’ files such as .htaccess (if you have any). Same for your PC.
While it’s a good idea to keep a copy of your site on your local PC – some users may want to directly copy their files from server to server, especially if they don’t have a broadband connection or their upload speed isn’t great. In this case you can use SCP, log into your server by SSH and type the following:
Where accountnamehost is the name of your account on your host machine (the machine you are moving from) and accountnamedest is the name of your account on your destination machine (the machine you are moving to). And ip.address.here being the ip address of your new server. You will be asked for the password of your account on your new server before proceeding. Be sure to test this on a ‘test’ directory before the final copy though.
4) Creating an empty database on your new server
Create a new database on your new server in your usual way. If possible, keep the same database name, username, and password. Or, you’ll need to edit the following file with the new info and upload it to your new server: Includes > config.php
5) Inserting your site’s database
Log in to your new server via SSH, and type the following:
Replace databaseuser with the NEW User that you just created in STEP FIVE
Replace databasename with NEW Database Name you just created in STEP FIVE
Replace /path/to/backupname.sql with the path where you uploaded the copy in step six.
You will be asked for a password. Type in the NEW password as created in STEP FIVE and press Enter. Your snapshot will then be saved.
6) Changing the nameservers for your domain
Now you simply need to log in to your domain registration company’s website and change the nameservers for your site’s domain over to your new server. If it’s a .com it shouldn’t take too long for the changes to propagate, but it can take up to 24-48 hours.
You will need to go into the Admin Control Panel to turn the site back on – but that should pretty much be it! To test whether you are on the new or old server, simply upload a graphic to the new server, something like test.gif. Then if you can reach it via the site you’ll know you’re on your new server.
If you don’t fancy going it alone and would prefer someone do it for you, contact me with details of your site and I’ll get back to you with more info.
As usual, this guide is provided with no warranties or guarantees – use at your own risk.Tags: linux, mysql, server admin