Loading
Cancel
Webmail Login
Control Panel Login
How to move/migrate OpenCart to another hosting/server guide
.CO.UK ONLY £5.33
Find your perfect domain here

How to move/migrate OpenCart to another hosting/server guide

How to move OpenCart to a new host / Server

OK, so you're currently using a hosting company that is slow or unreliable, your OpenCart site keeps slowing down or is non responsive and you want to move to someone else? Problem is it can seem complicated to move hosting companies and without the right guide you can end up losing sales and time. Well the good news is we've taken the time to write up a complete step by step guide on how to move OpenCart to a new server that even a web 'newbie' can follow. Simply follow the guide below and you'll be leaving your old hosting company with ease.

If you haven't got hosting already, why not check out our OpenCarth Hosting UK page.

Move servers

What do I need?

  • FileZilla : This is a FTP program which can be downloaded for free from https://filezilla-project.org/download.php?type=client. You can use another FTP program if you prefer but the guide below will provide detailed images using FileZilla.
  • Maintenance Mode : Your OpenCart website must be in maintenance mode before you start the backups.
  • A new hosting account : Our 1 Nut Linux can be purchased from here which will run an OpenCart website quickly and costs £47.40.
  • TIP : Contact your registrar and ask them to update your time to live (TTL) to the shortest time possible (e.g. 3 hours).

Step 1a : Backup your old website + database : Automatic way

Many hosting companies have an automatic backup feature (ourselves included) which means you can backup your website and database automatically. If yours has this feature, we suggest using it and skipping to step 2. 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 1b : Backup your old website + database the old fashioned way!

The first thing we need to do is backup your website files. Open up FileZilla (or your favorite FTP program) and enter your current host's FTP Host, username and password into the top boxes then click the Quickconnect button. If you don't know what these settings are then you can usually find them in your control panel with your current hosting company. Failing that, you can contact your host and ask them for these.

Opencart FTP Download

Once connected, you will need to navigate to where your OpenCart website is located. This is usually in your public folder called Public_html or Htdocs. If you installed your OpenCart website into a sub folder e.g. yourwebsite.co.uk/shop, then you will need to find your 'shop' folder.

Double click on your public folder to open it.

public_html

You should now see your website's files. We need to double check you are in the correct folder for your OpenCart files. Look for the below three files. If you can see these you are in the correct location.

  • config.php
  • hide_config_files.php
  • index.php

If you can't see these files then you will need to look inside your other folders. If you installed your OpenCart store in a sub folder e.g. yourdomain.co.uk/shop then look for your 'shop' folder and double click it to open it. Then look for the above files.

Once you are in the correct location, you will need to select all the files and folders. To do this, left click once on config.php and press the 'CTRL' button and the 'A' key at the same time (command-A on a Mac). This will change all the files to be selected. You can now drag the files into a folder of your choice (left click on one file and drag them over a folder on your computer). We suggest having a folder on your desktop called 'old website' and downloading the files into here.

Download Opencart Files via FTP

You will see a lot of connection and download text show in the top bar. Once this has stopped you should have all your OpenCart files downloaded to your computer.

Next, we need to download a copy of your OpenCart database. To do this, we will use phpMyAdmin. You will need to contact your current host and ask them for instructions on how to access phpMyAdmin for your database. Usually this will be under your control panel in a manage MySQL databases section.

Once in phpMyAdmin, click your database from the left hand menu.

OpenCart Database

You should see a list of tables related to open cart, starting with oc_ e.g. oc_address,oc_affiliate etc.

Next, click the export tab at the top.

Export OpenCart Database

Click the custom button then click the 'Select All' link to highlight all of the OpenCart tables.

Export database settings

Finally choose zipped from the 'Compression' drop down, then scroll down and click the 'Go' button.

Ziped OpenCart databse

You will be asked to save this to your computer. Make sure you remember where you save it to as you will need it later.

Step 2 : Upload your OpenCart Files to your new server

Now you have a copy of your website, we need to upload it and restore it on your new hosting/server. If you have purchased hosting with Squirrel Hosting then you can follow this guide exactly. If you're using another company for hosting, you will need to contact them for details on how to connect to your hosting via FTP and how to setup/connect to your database.

Open up FileZilla and connect to your new hosting company. Squirrel Hosting customers check your welcome e-mail for your FTP details. As your domain is still technically loading up your old hosting company at this stage, you will need to use the host's IP address instead of ftp.yourdomain to connect.

Opencart FTP upload

Double click on your public folder to open it up (for Squirrel Hosting customers, double click public_html).

public_html

Next, we need to upload all the files you downloaded in step 1 (do not upload your MySQL database).

To do this open up the folder where your files are stored and highlight them all, then drag them over onto your public folder.

Upload OpenCart via FTP

Step 3 : Create a MySQL Database

Now we need to create a new database on your new hosting. This can vary depending on which hosting company you choose to use. For Squirrel Hosting customers, simply follow the below steps. For other hosting companies you will need to contact them and ask how to set up a MySQL Database. You will also need to make a note of the database hostname, username, password and database name then skip to step 4.

For Squirrel Hosting customers only, load up your eXtend control panel (see your welcome e-mail for details on how to do this) and click the MySQL Databases icon.

MySql databases icon

Next, enter your desired username in the username box and then click the 'Generate Password' button. Finally click Create.

Generate database password

Scroll down to the bottom of the page and under the 'Manage MySQL Databases' section you will see the database you have just created. Make a note of the following;

  • Username (including any - )
  • Password (hover over to view it)

OpenCart database username and password

Step 4 : Upload your OpenCart Database

We now need to load phpMyAdmin on your new hosting to import our OpenCart database. Again if you are with a company other than Squirrel Hosting you will need to contact them for details on how to access your database. For Squirrel Hosting customers, click the 'manage database' button under your 'MySQL databases' button in eXtend.

Manage database

Once in phpMyAdmin, click your database menu on the left.

Import database tab

Click the 'Choose File' button and select the OpenCart database you made a backup of in step 1. Then scroll down to the bottom and click the 'Go' button.

Choose Opencart database

This may take a few moments to process depending on how big your database is.

uploading database

Once complete, you should see a message stating "Import has been successfully finished".

Import has been successfully finished

You have now restored your database and website files.

Step 6 : Update your config files

We now need to update your config.php and admin/config.php files to have the correct settings. You can either do this via FileZilla (FTP) or edit the files on your computer then upload them via FileZilla. If you do upload them, make sure they go in the correct location.

For the purpose of this guide, we will update them via FileZilla.

Open up FileZilla and connect to your new hosting package. Double click on your public folder (public_html). Next, right click on your config.php file and select 'View/Edit' (if you have installed your OpenCart in a sub folder, you will find your config file in there.)

View/Edit config.php

The file should now open up for editing. In here you will need to edit a few lines of code. Find the lines:

// DIR
define('DIR_APPLICATION', '/home/sites/YOUR-DOMAIN/public_html/catalog/');
define('DIR_SYSTEM', '/home/sites/YOUR-DOMAIN/public_html/system/');
define('DIR_DATABASE', '/home/sites/YOUR-DOMAIN/public_html/system/database/');
define('DIR_LANGUAGE', '/home/sites/YOUR-DOMAIN/public_html/catalog/language/');
define('DIR_TEMPLATE', '/home/sites/YOUR-DOMAIN/public_html/catalog/view/theme/');
define('DIR_CONFIG', '/home/sites/YOUR-DOMAIN/public_html/system/config/');
define('DIR_IMAGE', '/home/sites/YOUR-DOMAIN/public_html/image/');
define('DIR_CACHE', '/home/sites/YOUR-DOMAIN/public_html/system/cache/');
define('DIR_DOWNLOAD', '/home/sites/YOUR-DOMAIN/public_html/download/');
define('DIR_LOGS', '/home/sites/YOUR-DOMAIN/public_html/system/logs/');

You will need to update these to your correct path. Contact your hosting company for the full path to your public folder. (for Squirrel Hosting customers, use /home/sites/YOUR-DOMAIN/public_html/ . Make sure to replace YOUR-DOMAIN with your domain without the www. e.g. /home/sites/mywebsite.co.uk/public_html/)

Next, you need to update your database connection settings. Find the below:

// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'your-old-opencart-databse-username');
define('DB_PASSWORD', 'your-old-opencart-databse-password);
define('DB_DATABASE', 'your-old-opencart-databse-database);
define('DB_PREFIX', 'oc_');

You will need to replace these with the new details made in step 3;

  • DB_HOSTNAME = Your database host (usually localhost). Squirrel Hosting customers, use localhost here.
  • DB_USERNAME = Your Database username.
  • DB_PASSWORD = Your Database password
  • DB_DATABASE = Your database name (Squirrel Hosting customers, use your database username here.)

Once you have updated these, save the file and click back to FileZilla. It will ask you if you wish to upload the file as it has changed. Click 'Yes' to this.

Upload config.php to server

Next, we need to make the file 'read only' (CHMOD it to 444). On most servers, this is 444. To do this, right click on the config.php file again and click 'File Permissions'.

edit Config.php file permissions

In the popup box, enter 444 in the number area then click 'OK'.

Chmod config.php to 444

This file is now non editable. If you find you have made a mistake in what you have typed and you need to re-edit the file, you will need to re do this last step and enter 777. Make sure you DON'T leave this file CHMOD to 755 or you may leave your site open to hackers!

Next, we need to do the same edit with the admin/config.php file. Double click on your OpenCart admin folder.

OpenCart Admin Folder

As we did last time, right click on the config.php file and click 'View/Edit'.

edit admin config.php

As we did before, update the below to show your correct path.

// DIR
define('DIR_APPLICATION', '/home/sites/YOUR-DOMAIN/public_html/admin/');
define('DIR_SYSTEM', '/home/sites/YOUR-DOMAIN/public_html/system/');
define('DIR_DATABASE', '/home/sites/YOUR-DOMAIN/public_html/system/database/');
define('DIR_LANGUAGE', '/home/sites/YOUR-DOMAIN/public_html/admin/language/');
define('DIR_TEMPLATE', '/home/sites/YOUR-DOMAIN/public_html/admin/view/template/');
define('DIR_CONFIG', '/home/sites/YOUR-DOMAIN/public_html/system/config/');
define('DIR_IMAGE', '/home/sites/YOUR-DOMAIN/public_html/image/');
define('DIR_CACHE', '/home/sites/YOUR-DOMAIN/public_html/system/cache/');
define('DIR_DOWNLOAD', '/home/sites/YOUR-DOMAIN/public_html/download/');
define('DIR_LOGS', '/home/sites/YOUR-DOMAIN/public_html/system/logs/');
define('DIR_CATALOG', '/home/sites/YOUR-DOMAIN/public_html/catalog/');

Then edit your Database settings:

// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'your-old-opencart-databse-username');
define('DB_PASSWORD', 'your-old-opencart-databse-password);
define('DB_DATABASE', 'your-old-opencart-databse-database);
define('DB_PREFIX', 'oc_');

Your database settings will be the same as you entered in your other config.php file earlier. Once edited save the file then confirm the upload on FileZilla.

Upload admin config.php Opencart

Finally, CHMOD this file like you did with your other config.php (right click 'File Permissions') to 444.

Step 6 : Update name servers

At this stage, we suggest you update your domain's name servers to your new hosting company. To do this, contact your registrar (the company you purchase your domain with) and ask them to update your name servers to your new hosting company's (Squirrel Hosting name servers are ns1.mainnameserver.com and ns2.mainnameserver.com.) This can take up to 48 hours to complete. If you asked your Registrar to update the TTL time (see 'what I need guide' at the top of the page) this will be a lot quicker.

Step 7 : Test then remove Maintenance Mode

Once you are happy your website is fully functional, simply take your site out of Maintenance Mode.

Remember if you used this guide let us know in the comments below. We are always happy to hear we've helped someone. Also if you spot anything you think could be done better or if you get stuck at any point, drop a comment and we'll do our best to help (even if you're not hosted with us).

OpenCart Migration FAQ

OpenCart isn't sending any confirmation order emails out.

This can often happen when changing hosts. This is usually down to the e-mail settings you have.

  1. Make sure the e-mail address your OpenCart sends e-mails from is created on your new host. Some hosts (ours included when not using SMTP) won't allow mail to be sent via an e-mail address which does not end in the domain name of the site. e.g. if your site is www.mystore.co.uk then the e-mail must end in @mystore.co.uk
  2. If the mail box is set up, you may have the incorrect settings in your OpenCart. Log into your admin and move over 'system', click settings then click the mail tab. Try changing your mail protocol to Mail if it's on SMTP. If this fixes your issue, you know the SMTP settings you had installed were incorrect. Switch back to SMTP then update the SMTP Host, username etc to match your new host.

How do I move OpenCart from a localhost to a New Server?

Follow this guide above but when it comes to editing your config.php files, make sure to edit the URL to reflect your new URL. e.g. instead of http://localhost enter your domain.



Leave a comment

Has this guide helped you? Have an idea for a guide or need help? Let us know below.

© Copyright 2014 | Squirrel Hosting Limited
Company Number 9031308