Sydney: Moving a Magento eCommerce site to a new domain name by copying a current installation can be puzzling task if you don’t know where to commence. If you find yourself in need of doing this, use this article to save you some headaches.
Step 1 - Setup the new domain
It might go without saying, but the initial step is to build up the new domain’s web hosting with the needed Magento dependencies, normally just the LAMP stack. Verify that you can load up a PHP page on the new domain prior to going any further just to take another variable out of the equation.
Step 2 - Export/Import the MySql Database
The next step is to export the MySql database from the current eCommerce Magento site and use the resulting file to import into the new Magento site. As a Magento database can be quite large, it is recommended to use the command line to perform a mysqldump operation.
Other methods for importing and exporting a MySql database are also available.
Step 3 - Copy the existing installation directory to the new domain
The basis you’re going through all of this difficulty is to launch a new site using a current site as a baseline. For this reason, you want to copy/paste the complete installation directory from the existing install into the new domain web root folder. Usually you’ll want to compress the directory before you move it to speed things along if you’re going between servers.
Then after you move the compressed archive, expand the archive into your new webroot.
Now that the archive has been expanded into your new webroot, you’ll most likely need to adjust the ownership of the files - a commonly ignored step.
Step 4 - Adjust the Magento configuration
You’ll now need to revise the Magento configuration for the new site. This entails editing the config file to connect to the new database location and editing the database directly to set the apt domain name.
To adjust the config file, edit the contents of path/to/magento/app/etc/local.xml so that the database connection information matches your new parameters.
Next, open up phpMyAdmin or another MySql management tool and connect to your new database. Open the table named “core_config_data” and edit the values for “web/unsecure/base_url” and “web/secure/base_url” to match your new domain name.
Step 5 - Clear the Cache/Sessions
The final step is to clean-up the cache and session files that may be present from the old set up. To do this, navigate to path/to/magento/var/cache and delete everything from the folder.
Now, do the same for the session folder at path/to/magento/var/session
At this point you should be able to load up your new Magento installation on the new domain without having to start from scratch.