Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

Recently I've had the task of migrating my dad's online store from the old web host to a new hosting provider. At first this seemed like a scary thing to do, but as I found out it was actually very straight forward and simple. This shows you the steps I took to move the entire PrestaShop installation and store content from one hosting provider to another.

Before I get started, lets define some things...
 Definitions
Host A = old web hosting provider, this is where we're moving from
Host B = new web hosting provider, this is where we're moving to
PrestaShop is running with MySQL.
You can log in as admin into PrestaShop.
You have file system access on Host A and Host B.
You have MySQL admin access on Host B.


The version of PrestaShop in my case was 1.4.6.2, however the same kind of process should be applicable to all versions.

Since this kind of migration requires a name server change at your domain registra, it can take up to 24 hours to take effect. Be prepared for an extended down time for the store in other words!

Step 1 - Put the store into maintenance mode.
This is done on Host A. On the Preferences tab change Enable Shop to No and save the settings. This will ensure that no new transactions come through, no new customer registrations are made, etc...basically it's to lock the shop down for moving.
mig8.png


Step 2 - Take a DB Backup
This is done on Host A. Go to the Tools tab, then to the DB Backup page. Agree to all the questions and generate the backup. This should not take too long.
mig1.png


Download this backup to your computer.
mig2.png




Step 3 - Transfer all the store files from Host A to Host B.
This can be done any number of ways, I chose to take a file system backup on Host A, download it to my computer and extract it's contents. I then compressed all of the files inside the public_html directory into a zip and uploaded that to Host B. This file was then extracted on Host B. I won't go into details of transferring these files over, but basically what needs to happen is to copy all of the PrestaShop files from Host A to Host B.

Step 4 - Get the DB details.
I didn't know any of the database details of the original installation, luckily there is a configuration file that stores all of these. In the PrestaShop directory there should be another directory called config, this in turn contains a file called settings.inc.php. It will have a number of configuration definitions, but the ones we need are listed below, take note of those in your configuration.
 config/settings.inc.php
define('_DB_NAME_', 'Your DB name');
define('_DB_USER_', 'Your DB user');
define('_DB_PASSWD_', 'You DB password');


Step 5 - Create a new DB and user on Host B.
There are different ways of doing this, in my case I chose to use CPanel to create a new MySQL database and user. The idea is to use the details gathered in step 4 to create this new database on the new hosting provider, Host B.
mig3.png


After the database is created a user needs to be created in MySQL.
mig4.png


Once the user is created, add this user to the database that was created and give it all privileges.
mig5.png


Step 6 - Import the DB Backup into the new DB.
The easiest way to do this is to use phpMyAdmin. This is usually installed already by any decent hosting provider. This step is done on Host B. In phpMyAdmin, select the new DB that was created, click the Import tab, select the DB backup file that was downloaded earlier and click Go.
mig6.png


If everything goes well, something like this will be displayed...
mig7.png


The shop is essentially moved over now, but the Internet doesn't know about the new location yet. So onto the next step.

Step 7 - Change the domain name server details to point to Host B.
This is done at the domain registra level. Basically wherever your shop's domain name is registered is where you need to change this information. In my case I transferred the domain from the old host to the new host so my change was done on the new host. I won't go into details on how to do this since there are many ways of doing it and if you're not sure contact the new web hosting provider to show you how.

After the name servers are changed it can take anywhere between an hour to 24 hours for changes to take effect. This is due to how the Internet name servers work and there is no way around this.

Step 8 - Wait for the name servers to update and point to your new host, Host B.
How do you know that everything switched over to the new host? Right now you don't because both Host A and Host B have the same identical shop and database details.

As a handy trick you can edit the index.php file inside the PrestaShop directory on Host B. Simply comment out everything in the file, or even better just make a backup of this file. Then put in something like this into the file at the very top:
 index.php
<?php die("Maintenance mode, shop returning shortly."); ?>


This will force the shop to display the "Maintenance mode, shop returning shortly." message instead of the usual maintenance screen. Once you see that message, you can be sure that the shop has been switched over to Host B.

When you do see this message, either restore the original index.php file or uncomment the parts that were commented out and make sure to remove that line that was added from above.

Step 9 - Clear your browser cache.
This is optional but as a precaution it is a good idea to clear the browser cache so you know that you're getting all the fresh files from Host B when you access the shop and that there are no stale files left over from Host A.

Step 10 - Disable maintenance mode.
Login as admin into PrestaShop and enable the shop. This is similar to Step 1, except you select Yes to enable the shop.

You're done!

Note: I didn't cover moving email addresses over as that's outside the scope of this article, but yes you do need to think about that. The PayPal details usually don't need to change so you can start receiving payments straight away.

Good luck!

-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.