How to migrate ZenCart to another server in detail
So you want to migrate your ZenCart site to a new hosting company? The below guide will take you through every step in fine detail showing you where to click and what to type where.
Please note, this guide will work for any hosting company but if you have hosting with us, you will find it even easier as some steps are hosting company specific.
It's also worth noting this guide was written when ZenCart was on version 1.5.1. It should work for older versions and possibly newer versions.
This guide also assumes your ZenCart site is in your root folder e.g. your-site.com instead of a folder e.g. yours-site.com/store. If it is in a folder you will need to alter the steps accordingly to include this.
OK, strap on your ZenCart seat belt, let's migrate!
What do I need?
- FileZilla or FTP program
You will need to upload and download files during this tutorial. To do this we are going to use a program called FileZilla. This is a free FTP program which will make this whole procedure much much easier. If you don't have FileZilla. you can get a free copy here: https://filezilla-project.org/download.php?type=client.
- Set website into maintenance mode
You will also need to set your website into maintenance mode. To do this, log into your admin, move over 'Configuration' and click 'Website Maintenance.' Click on the Info icon next to Down for Maintenance: ON/OFF, then click the Edit button. Finally set this to True and click the update button.
- New hosting set up with your domain as a reference
To do this with Squirrel Hosting visit http://squirrelhosting.co.uk/domain-needed and enter your domain in the option 2 box. Then order hosting during the checkout.
Step 1 Update to the latest version.
This step isn't mandatory but it's highly recommended. It should show you in the top right of your admin area which version you are currently using. Check this against the version on the home page of http://www.zen-cart.com. If your version is lower than the one on the site, we strongly suggest updating your ZenCart install first.
Step 2a : Backup your old website + Database : Automatic way
Some hosting companies provide an automatic backup feature (ourselves included) which can backup your website and your database for you. If yours has this, we suggest using it and skipping to step 3. If yours doesn't have this, don't worry we've listed all the steps below needed to backup your site's files and databases.
Step 2b : Backup your old website + database the old fashioned way!
First we will backup your website's files. Create a folder on your computer called "Old Website". Open up FileZilla and input your website's FTP details in the top and click 'connect'. You can usually find these in your hosting control panel. Failing that contact your Host asking for the FTP Host, FTP Username, FTP password and if needed FTP Port.
FileZilla. will now connect to your website's FTP and display your site's files. Next we need to find your ZenCart files. If you haven't specified a sub folder to run your store from e.g. yoursite.com/store, then your files should be in the public folder (usually called public_html or htdocs). If you have specified a folder then you will need to double click the folders until you find your site's files.
TIP: Look for index.php, ipn_main_handler.php and page_not_found.php. Once you see these you are in the correct location.
Highlight all of these files by clicking any of the files once and pressing CTRL+A on a PC. Then drag the files over your 'Old Website' folder to start downloading them.
Once complete, you will have a full backup of all your site's files.
Now we need to backup your MySQL Database. For this we need to use a tool calledphpMyAdmin. Open your hosting control panel and look for this or for anything stating MySQL Databases. UsuallyphpMyAdmin can be loaded from there but if not, contact your hosting provider who should be able to guide you to the right place.
Once inphpMyAdmin. click your database from the menu on the left
Next, click the export tab at the top.
Select "Custom - display all possible options" and make sure all the tables are selected. If not click the 'Select all' link.
Under compression, choose 'Zipped' from the drop down.
Click the Go button and save the file to your computer.
You now have a copy of your old database.
Step 3 : Get a copy of ZenCart and update your name servers.
Generally we recommend you update your name servers to your new hosting company's settings at this stage to make things easier. Contact your old hosting company for details on how to change these. You will also need to contact your new hosting company to find out what their name servers are. Squirrel Hosting's name severs can be found here. Name servers can take up to 24 hours to update. This will result in a little downtime but makes the procedure much easier. If you are more fluent on installing ZenCart on a temporary domain then you could leave this step till later on.
Visit http://www.zen-cart.com and download a copy of ZenCart which matches the version you are currently using for your website e.g. if you are running ZenCart 1.3.9.h then download ZenCart 1.3.9h. It is imperative you download the exact same version of ZenCart that you are currently using. Do not be tempted to try and migrate and upgrade, this can cause multiple issues and is more effort than it's worth.
Step 4 : Upload the downloaded copy of ZenCart to your website
We now need to upload the version of ZenCart you downloaded in step 3 to your new server. If you know how to upload files via FTP then upload ZenCart and skip to step 4. If you don't know how to upload files, install FileZilla and follow the steps below.
Step 3a : Open Up FileZilla and enter your FTP login details in the address bar. For Squirrel Hosting customers, this information is in your welcome e-mail and in your eXtend control panel, make sure to unlock your FTP first. Then click the connect button.
You will see a lot of text appear and if you have entered the correct login details (and unlocked the FTP) you should see several folders appear in your filename box. Double click the folder which represents your web accessible folder to open it. This is the folder that your hosting company has stated you need to place your website in. On Squirrel Hosting servers, this folder is called public_html.
Next we need to upload the files from the ZenCart download. The file you downloaded from ZenCart will be a .zip file. Do not upload this file, instead extract the files inside it to a folder on your computer. Once extracted, open the folder and highlight all the files. Drag the files onto the large white area on the right of FileZilla (the filename area) OR drag over the public_html folder in the top box. If you had your zenCart installed into a folder e.g. yoursite.com/store you will need to create a folder called store inside the public folder (right click create directory) and upload the files to here instead of directly in the public_html.
FileZilla will now upload all the files to your server. This may take a while depending on your internet connection speed.
Step 5 : Updating the zenCart files permissions and configure.php
This step can be skipped on most modern Linux hosting packages (including Squirrel Hosting). If you hit trouble when doing step 8 during the 'System Inspection page' follow the below steps.
Whilst still in FileZilla, double click on the 'includes' folder.
In the bottom half of the box, right click on dist-configure.php and click rename from the popup menu.
The dist-configure.php should now be editable. Change this to configure.php
Next, you need to change the permission on this file to writable. You will need to contact your hosting provider and ask them what the number to CHMOD a file is in order to make it writable. Usually this is something like 755. Squirrel Hosting customers use 755 for folders and 644 for files. For the rest of this section, we will assume your hosting has stated your writable CHMOD settings are these.
Right click on configure and click File Permissions.
In the popup box, enter your CHMOD Number e.g. 644 then click the OK button.
Next we have another dist-configure.php file located in your admin folder. This will also need to be renamed and CHMOD to the correct setting. Scroll up in the top half of the FileZilla box and double click the admin folder. Next double click the includes folder. In the bottom half of the FileZilla box, you will see a file called dist-configure.php. Repeat the above method to rename this to configure.php and CHMOD it to writable. (644).
Now we have both our configure.php files set up we need to CHMOD some folders to writable.
In the top half of FileZilla right click on the 'cache' folder and click 'File Attributes'.
In the popup box, enter your writable. CHMOD number in the box (755) and leave 'Recurse into subdirectories' un-ticked. Then click 'OK'
Next we need to repeat this procedure for the following folders.
Next we need to CHMOD some more folders but this time we also need to CHMOD the folders contained within these. I will take you through how to do the attributes folder listed below, then you will need to repeat the procedure for the remaining folders below.
- images/attributes (shown in the below steps)
Double click on your images folder then right click on the 'attributes' folder and click 'File Attributes'.
In the popup box enter your CHMOD number but this time tick 'Recurse into subdirectories' and select 'Apply to directories only'. Then click the OK button.
Now repeat this procedure for
Step 6 : Set up your new MySQL Database
Now we need to set up a database on your new server for your ZenCart site. Squirrel Hosting customers can jump to the the below steps. If you are not a Squirrel Hosting customer, you will need to contact your hosting company for details on how to do this. You will also need to make a note of the databases connection details including host, username, password and database name.
For Squirrel Hosting customers, log into your eXtend control panel and click the MySQL Databases icon.
Next, enter the desired username and password you would like for your new database. For a hard to crack password click the 'Generate Password' button. Then click the create button.
When the page refreshes you should see your database appear at the bottom. This will contain your database username and password. Write these down as you will need them later.
Step 7 : Find your database DB_PREFIX setting
Before we run the ZenCart install we need to find your DB_Prefix. It may be your database doesn't use a prefix but we need to double check this. You will be asked for this during the install and it needs to match up with your the old servers. Open the backup of the old servers files that you made in step 2 and look in the includes folder. Then open up configure.php with a plain text editor such as note pad.
Do not open configure.php with any rich text editor such as Microsoft word or wordpad. This can corrupt the file.
Once the file has opened look for the line:
define('DB_PREFIX', 'THIS IS YOUR PREFIX'); // prefix for database table names -- preferred to be left empty
When you find the line, what ever is stated in the 'this is your prefix' box above is your database prefix. So for example, if your database prefix was zen_ it would show:
define('DB_PREFIX', 'zen_'); // prefix for database table names -- preferred to be left empty
Write your database prefix down then load up the zenCart install in your browser. To do this visit /zc_install e.g. www.your-site.com/where-you-installed-zencart/zc_install.
Step 8 : The ZenCart install
Now we have all the details and files needed to setup your site on the new server. Open up the ZenCart installer (www.your-site.com/zc_install) in your browser. You may see a "hello, thank you for loading Zen Cart" message. If so, click the "Click here" link. If you don't see this page then you should see the page mentioned below.
You should now see the ZenCart setup welcome screen. Click the continue button to continue.
Select "I have read and agree to abide by the Terms and Conditions as stated above." then click continue.
You should now see the System Inspection page. If you are on Squirrel Hosting servers you will not fail any of the server inspections. If you are not on our servers and any of these fail you will need to contact your own hosting provider before continuing.
It will also check to see if you have the file and folder permissions all set correctly. If you fail any of these then you will need to do Step 5 above.
Click the Install button to continue.
You should now see the Database Setup page. This is where you enter your new database settings which you made in Step 6. For Squirrel Hosting customers, use 'localhost' in your Database Host and your database username for the 'Database Username' and 'Database Name'.
The next step is important to get correct. Enter your DB_PREFIX from step 7 into the 'Store Identifier (Table-Prefix)' box. Enter this exactly as you saw it in your configure file (including any capital letters). If it's not entered exactly correct, your website won't load. Squirrel Hosting customers can ignore the 'Session/SQL Cache Directory' box as this will be automatically filled in for you. If this isn't filled in, contact your hosting provider. If you ran your ZenCart site in a folder, make sure to update the session address to include this.
Then click the 'Save Database Settings' button.
If you have entered the incorrect database details, you will receive an error message stating:
"Connection to Database failed, Access denied for user 'xxxx'@'xxxx' (using password: YES)".
Check the Database Host, Database Username, Database Password and Database Name. One of these is incorrect.
Otherwise you will be redirected to a page showing you the install process of ZenCart (see below).
The next few steps are site specific. If you are using Squirrel Hosting, everything should be filled in for you. If you're not using us and they aren't filled in, you will need to speak to your hosting provider. Don't forget some steps will ask for paths, if you are installing in a folder make sure the folder is specified (again this should be automatically filled in for Squirrel Hosting customers).
Finish the install then proceed to the step below.
Step 9 : Move your configure.php files
On your computer (not on your new hosting) you should have the backup of your website from your old hosting company (made in step 2). We need to move the two configure.php files out of this backup.
Open your backup and navigate to the includes folder. You will see the 1st configure.php file in here, move this file out of the backup to your desktop (or somewhere else safe). Next open the includes folder located in the admin. Again move the configure.php file to somewhere else on your computer. When complete, you should be left with a backup of your old website with no configure.php files.
TIP : Before moving on, double check the configure.php files have been removed from your backup. If you proceed without doing this you will overwrite your new configure.php file and have to start this guide all over again!
Step 10 : Upload your old ZenCart files
Connect via FTP to your new hosting (using FileZilla). Open up your old hosting company ZenCart backup on your computer and navigate until you can see admin, cache, docs, download etc folders. Highlight every folder/file in here (on a PC press the CTRL key and the A key at the same time). Click and hold on one of the files then drag the files over and onto the public_html folder in ZenCart (like you did in step 4). This should now start the upload of your old site's files.
You will get a message stating that the "target file already exists". Click the Overwrite button and select "Always use this action". Finally check the 'Apply to current queue only' and click OK.
Step 11 : Switch to the correct database
We now need to remove all the data in your new database and import your old hosting database. To do this we will use a program called phpMyAdmin. Open your hosting control panel and look for this or for anything stating MySQL Databases. Usually phpMyAdmin can be loaded from there but if not, contact your hosting provider who should be able to guide you to the right place.
For Squirrel Hosting customers, log into your eXtend control panel and click the MySQL Databases icon.
Then click the 'manage' button next to your new ZenCart database. Once phpMyAdmin loads, click your new ZenCart database from the menu on the left.
You should now see all your new database tables. Scroll down to the bottom and click the 'Check All' link then from the drop down menu choose 'Drop'.
On the next screen it will ask you to confirm you wish to drop the tables. Click the yes button. This will then drop all your new ZenCart database tables.
Next click the 'Import' tab at the top.
Click the Choose File button and select your old ZenCart Database you made in step 2. Then click the 'Go' button.
You should receive an 'Import has been successfully finished' message. If you didn't or you receive an error it may be your database file is corrupt or contains extra information regarding database names. This can often happen with an automatic backup. Jump back to step 2b and re-backup your old database. Then start at step 11 again to re import your database.
Step 12 : Fix Cache Key
Finally we need to download and run the Fix_Cache_Key utility. This will reset your session Directory Key so it uses the proper folder path. To do this visit http://www.zen-cart.com/downloads.php?do=file&id=8 and download the file. The download will be a zip file. Open the zip file and inside will be a file called fix_cache_key.php. We want to upload this to where you installed ZenCart.
Open up FileZilla and connect to your new FTP (as in step 4) and upload the file to your new hosting public folder. Squirrel Hosting customers drag the file over your public_html folder.
Then visit www.example.co.uk/open fix_cache_key.php in your browser (replace example.com with your domain name). If you have installed ZenCart into a folder you will need to ammend this, e.g. www.example.co.uk/YOUR-FOLDER/open fix_cache_key.php
You will see a 'Cache Settings Synchronization Tool' page appear. This will now automatically update your cache key for you.
Once complete, you will need to delete fix_cache_key.php.
In FileZilla, right click on delete fix_cache_key.php and click delete, then confirm the deletion.
Step 13 : Change configure.php permissions and delete the zc_install folder
All that's left is to CHMOD the includes/configure.php and admin/includes/configure.php to read only (444 on Squirrel Hosting) and delete the zc_install folder. To do this use the same process as you did in the above steps.
Step 14 : Enjoy your new ZenCart hosting!
Everything should now be working. Try logging into your admin and test your website. Make sure everything works before switching off maintenence mode.
Frequently asked questions
Q. I cant log into my admin area with the username and password.
A. First off, try using the forgot password link on your login page. If you don't get any e-mails through then the odds are that your e-mail settings are incorrect in ZenCart. This can often happen if you were using SMTP and when you moved hosts, your e-mail hadn't been set up again or uses a different SMTP setting. To get around this, log into your MySQL database via phpMyAdmin., click your ZenCart database from the left then click on the 'SQL' tab at the top. Enter the following code:
For ZenCart 1.5.x enter ;
DELETE FROM admin WHERE admin_name = 'Admin'; INSERT INTO admin (admin_name, admin_email, admin_pass, admin_profile) VALUES ('Admin', 'admin@localhost', '351683ea4e19efe34874b501fdbf9792:9b', 1);
For ZenCart 1.3.9 and older enter ;
DELETE FROM admin WHERE admin_name = 'Admin'; INSERT INTO admin (admin_name, admin_email, admin_pass, admin_level) VALUES ('Admin', 'admin@localhost', '351683ea4e19efe34874b501fdbf9792:9b', 1);
This will reset your username to Admin and your password to admin (note the capital A in the username)
Q. My site isn't sending out any e-mails when customers join or when an order is placed.
A. This means a setting in your ZenCart's configuration > E-mail Options is incorrect. Try switching your e-mail Transport method to sendmail. If this works then your SMTP settings are incorrect. Find your correct settings and update accordingly.
Many servers won't allow e-mails to be sent from an e-mail address that doesn't end in @yourdomain. Make sure if your website is trying to send e-mails, it's from an e-mail address that you have set up on the new hosting.
If this blog post has helped you or if you have spotted that's incorrect or could be done an easier way, why not let us know below and share the knowledge with others.
Leave a comment
Has this guide helped you? Have an idea for a guide or need help? Let us know below.