Moving Your Web Site To A New Web Host
Moving your web site can be time consuming and appear difficult. But using this as a checklist should be very helpful.
Backing up your old site including any MySQL data
This important first step will save you hours and preserve your scripts permissions and MySQL databases. Log into your old site via shell/telnet. Next, run this command which creates an archive of your entire site:
tar -cvf - /home/user_name/public_html | gzip -c > /home/user_name/site_files.tar.gz
In the above command, which is all on the same line you need to change the path to your site and the path where you wish to store the archive. Insure that you store the archive outside the folders/site you are backing up. If you don't have a special directory for your backups, use the MkDir command in your FTP client to create this directory. In the first example we are backing up all the files in the /domain.com directory and storing the archive outside/above this directory in the /site_files directory. In the second example we are backing up all the files in the /public_html directory and storing the archive outside/above this directory in the /user_name directory.
If you have MySQL data you wish to back up, run this command from shell:
mysqldump -uusername -pmypassword databasename | gzip -c > /home/user_name/public_html/mysql_backup.tar.gz
In the above example change: username to the username for the database you wish to back up on your old site, mypassword to this databases password, and databasename to the name of the database you wish to back up. Depending on the size of your database this command can take seconds or minutes.
Downloading Your Backup
Open your FTP client and log into your old site. Next, download the .tar.gz backup we just created to your local machine using Binary transfer.
Upload your backups to your new site and MySQL import
Hopefully your new virtual hosting plan includes a dedicated IP number for your exclusive use. Those with dedicated servers normally have this. A dedicated IP number will probably cost more but will permit you to test your new site immediately and may enhance your Search Engine rankings. Upload your .tar.gz backup to your new site inside the /public_html folder using Binary transfer. At the conclusion of your uploads, stay connected to your new site.
Decompressing your backups via shell/telnet
Log into your new site via shell/telnet. Issue the following command to determine where you are:
PWD or ls -la
The next step is to change to the directory where your backup are located. Issue this command: cd mainwebsite_html or it might be cd /home/username Next issue the following command and you should see the file names of your backup: ls -al Next, we need to decompress your backups with the following command. Please note, you must be located in the directory which contains these backup. tar -xzf site_files.tar.gz (or it might be:) tar -xzf mysql_backup.tar.gz
Moving files around via FTP
Hopefully, you are still connected to your new site via FTP. Click the Refresh button and you should see a new folder which is the result of decompressing your backup. Drill down into this folder structure which comes from your old site, until you reach the web site files. Shift click on all of these files and folders and then select Move files in your FTP client. In the remote destination folder field enter /public_html/ and click OK. Note that this command requires two "/" characters. Navigate back up the directory tree and click your Refresh button and you should see all the files and directories from your old site. You can even test this new site in your browser via the IP number like this: http://220.127.116.11. If your host provides a preview address it may be as simple as http://siteadmin.yourhost.com/yoursite.com/
If you are moving a MySQL database from your old domain, perform all the steps in the previous paragraph. Double check your old sites directory structure to insure you didn't leave any files behind in the move command and then select the folder at the top level from your old site and issue the delete files command in your FTP client. If you performed these steps correctly all your site files should be located in the correct directory, including your scripts. You should still have your .tar.gz backup which you can delete. Don't delete your MySQL file yet.
Set up your MySQL database for your new site
Log into your new sites Control Panel and create a new MySQL database. Copy and paste the data for this new database into Notepad for future reference and use. You will need all of this data in the next section.
Import your data into your new MySQL database
Log into your new site vis shell/telnet. Issue the following command to see where you are: ls -al Next you need to change directories to the location of your mysql_backup dump file which was contained in the archive. Issue this command: cd mainwebsite_html or it might be cd /home/user_name Verify that you are currently located in the correct directory via this command: ls -al You should see the name of your MySQL data file on the screen like this: mysql_backup.sql In the next step we are going to import your MySQL data into your new database. Note, you must be in the correct directory for this command to work. Issue this command:
mysql -u username -p database < mysql _backup.sql
Replace username with the username for the database on your new site. Replace database with the name of the database. Replace mysql_backup.sql with the name of the .sql file. You will be asked for your password before this command will run. Copy and paste it from your Notepad file to insure accuracy. Depending on the size of your database this command may finish in a few seconds or it could take several minutes. You will see a completed notice on the screen. Php/MySQL scripts may require you to edit a file which is sometimes called config.php or config_include.php. This file should contain the current MySQL database data on your new host. Copy and paste the appropriate data you saved in Notepad when you set up the new database. With a dedicated IP, you can test your new database via your browser. Navigate to it's location using your new sites IP number.
Cleanup & Testing
If the previous steps worked properly, you can delete your MySQL file and any remaining .tar.gz backup from your site. If your new site uses a dedicated IP you can test the pages with your browser. Some of your scripts will even run properly and others may not because of the following reasons which may require edits: • Path to Perl is not correct for your new site • Path to sendmail is not correct for your new site • The script includes a domain name variable so you will have to wait for propagation of your domain. • The script includes a server path variable like /home/domain/cgi-bin which you must edit for your new site • Php/MySQL scripts may require you to edit a file which is sometimes called config.php or config_include.php This file should contain the current MySQL database data on your new host. Copy and paste the appropriate data you saved in Notepad when you set up the new database.
Do not cancel your old hosting account yet. This provides you with a measure of protection in case you forgot some files and during the propagation of your new site, some folks will see your old sites and some will see your new site until propagation is completed.
Changing your DNS Name Servers and Propagation
The final step in this procedure is to change your DNS Name Server data with the registrar of your domain. You should not do this until you are absolutely sure your new site contains all the necessary files and everything is working properly. Your new host should have sent you an email with your new Name Server data. It will look something like this:
Log into the Admin of your registrar and copy and paste the new DNS Name Server data into the appropriate fields. The IP number is normally not required for virtual hosting accounts since your host's DNS should be automatically recognized by your registrar. If this is your own dedicated server, you may have to register your custom DNS Name Server data with your registrar before the change will be accepted. This procedures normally requires both ns1.controlservers.net and the IP number of 18.104.22.168. Save your setting and double check them. You have just started the propagation of your web site. A procedure where the Internet's 13 root servers notify every ISP in the world about the new location of your site. This procedure is rolling in nature and starts within 6 hours. It normally takes 24 to 48 hours. In rare cases, it can take up to 5 days with some ISPs. Make sure to clear your browser cache periodically. You may also clear your computers internal DNS cache by using
Start -> Run -> ipconfig /flushdns
on a Windows computer. After you can reach your new site with the domain name and not the IP number, immediately test the site again to insure that everything works. Five days after you started the propagation procedure you can cancel the hosting with your old host.