« Divine Performing Arts | Main | Streaming Music (PC to Hi-fi) »


Moving a Web Host to New Location

April 03, 2008

I have just completed relocating my web host account. It involved a number of blogs using Movabletype (ver 3.2)., a photo gallery (Gallery 1.5), and a personal diary (Wordpress 2.0) residing on my home server but making use of the MySQL server in my former web host.

The entire process was made easier as both my new and former hosts allowed shell access which enabled direct transfer of files from host to host. If I did not have shell access, it would have taken me at least 3 times longer to complete the transfer involving an extra step in downloading/uploading to and from my computer.

This is to document the steps I took for the relocation. It is not only for my own reference but may also help those who are contemplating a similar move.

1. First, make a note of the following:

Existing Web Server (this can usually be found in the web host control panel and is required because after the domain transfer becomes effective, it will no longer be possible to ftp using the domain name): web.old.com

Existing Web server: web.old.com

Existing MySQL server: mysql.old.com

Existing MySQL databases: db_1, db_2 … etc

Existing MySQL users: user1, user2 …. etc

New Web Server: web1.new.com

New MySQL server: mysql.new.com

2. Create domains in your new host. Note down the new DNS server.

These new domains will not become effective until changes are made in the Register. For example, hollymolly.com is registered in www.register365.ie. I will go to the register and update the DNS (typically in the form of ns1.xxxx.com, ns2.xxx.com).

It makes no difference whether to effect the change in DNS now or later after the entire transfer process is complete. If yours a busy site, do it after so that your site will remain accessible during the entire transfer process. Mine is not and I prefer to doing it right away as the change will take a few hours to propagate and my site will be up and running by the time the transfer is complete.

Doing it now will also enable logging onto MT control panel (in the new host) to make a few necessary adjustments by the time the transfer is done.

3. Create databases in the new MySQL server using the same db names as per existing.
# mysql -u root -p
mysql> create database db_1;
4. Create the same set of MySQL users with corresponding privileges.
mysql> grant all previleges to db_1 to user@yourhost identified by ‘password’;
mysql> flush previleges;
mysql> quit;
(if using phpMyAdmin, it can be configured to handle both your new and old MySQL servers from the same interface saving the trouble using two instances of phpMyAdmin, one for mysql.old.com and the other for mysql.new.com. Just add $i++ with specific server configurations in config.inc.php.)

5. Backup the existing databases.

Logon to the existing shell web.old.com (PuTTy is an excellent SSH client to do this) .
mysqldump —all-databases -u root -p > ~/db_backup.sql
This will create a text file db_backup.sql in your home directory. Leave this where it is for the moment.

(it is possible to do the above thro’ phpMyAdmin but take note of the size limitation imposed by it. The shell command is a lot easier.)

6. Backup the existing domain

While still in the old shell account
tar -cvf domain1.tar ~/domain1.com

This will compressed the entire content in domain1.com into a tar file domain1.tar. This file will be in your home directory.

Repeat this with other domains as follow (replace domainXXX.com with the actual domain name):
tar -cvf domainXXX.tar ~/domainXXX.com

7. Transfer and Uncompress the files

Logon to the new host web1.new.com

At the shell:
ftp web.old.com
(use sftp user_name@web.old.com if possible. It is more secure. Many hosts are now phasing out ftp)
Enter user name and password as required.
Make sure you are at the $HOME directory:
ls -l
Then
get db_backup.sql
get domainXXX.tar
These will transfer all your backup files from the old host to the new host.
mysql -u root -p < ~/db_backup.sql
This will import all your existing databases to the new MySQL server.
tar -xvf domainXXX.tar ~/domainXXX.com

This will copy all the content in domainXXX.com to your new host (repeat for other existing domains as required).

Almost there.

There is no need to delete the backup files. Move them to a backup directory as they provide a valuable snapshot of your web sites at the time of the transfer.

At shell,
cd ~/
mkdir backup
mv db_backup.sql ./backup
mv domainXXX.tar ./backup
8. The following adjustments are Software Specific.

a. Wordpress

Go to wordpress root directory (where you logon to wordpress) and edit wp-config.php using your favourite editor,

The only line that need change is
define(‘DB_HOST’, ‘mysql.old.com’);
Change this to
define(‘DB_HOST’, ‘mysql.new.com’);
Databases name and user name remain the same as we have made them to be previously in step 3 & 4.

b. Movable Type

Edit mt-config.cgi

Change
DBHost mysql.old.com
To
DBHost mysql.new.com
Change
TemplatePath /home/old path to your mt tmpl/mt/tmpl
To
TemplatePath /new path to your mt tmpl/mt/tmpl
** If using StaticWebPath for images, it needs attention as well to reflect the new filesystem path.

Logon to MT control panel (after DNS change became effective) and adjust the new site path under “Settings”.

c. Gallery

I took the opportunity to upgrade from Gallery 1.5 to the latest version 2.2.4.

Note down the albums directory. Install Gallery 2.2.4 in a new directory.

Towards the end of the Gallery 2.2.4 installation, there is an option to import existing albums. Importing existing albums by pointing to the albums directory.

Remap the old gallery url http://domainXXXX.com/gallery to point to the path of the new gallery 2.2.4 installation so that users accessing my old gallery 1.5 will automatically see the new gallery 2.2.4

d. Others

Some software may require a different version of php to run (for example, php4.4 instead of php5.0) or its own php.ini. Using a different version of php than the one provided by your web host or using a specific php.ini can be done:

Make a cgi-bin directory in the web-root directory if it does not already exist.

Copy php5.cgi or php4.cgi to cgi-bin
Copy php.ini to cgi-bin

Add .htaccess to root:
Options ExecCGI
AddHandler php-cgi .php
Action php-cgi /cgi-bin/php.cgi
Change permission:
chmod 644 $HOME/domainXXX.com/.htaccess
chmod 755 $HOME/domainXXX.com/cgi-bin
chmod 750 $HOME/domainXXX.com/cgi-bin/php.cgi
chmod 644 $HOME/domainXXX.com/cgi-bin/php.ini

Posted to Web at April 3, 2008 05:11 PM :   Furl this page Furl It!   del.icio.us del.icio.us

Comments




amazon books

Post a comment

Thanks for signing in, . Now you can comment. (sign out)

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Remember me?