Khalil Ghâñmî

0 %
Khalil Ghâñmî
Développeur full-stack
  • Residence:
    Tunis
  • City:
    Bardo
  • Age:
    30
French
English
arabe
  • HTML 5 / CSS 3
  • Bootstrap
  • JavaScript / Jquery/Ajax
  • ReactJS
  • API
  • Angular
  • PHP/Mysql
  • Python
  • Java
  • Wordpress
  • OpenCart
  • Illustrator | Photoshop | Premier Pro | Animate
  • OVH | Godaddy | Vipdomaine | Zenhosting | LWS | Hostgator
  • Cpanel
  • Google Search | Google sheets | Google docs | Office

HOW TO MIGRATE OPENCART 3.X+ TO A NEW HOST / SERVER

6 January 2022

HOW TO MIGRATE OPENCART 3.X+ TO A NEW HOST / SERVER
Quick Guide Steps

Below are the basic steps, full detailed steps are listed further down the page.

Backup the OpenCart 3 files/folders
Backup the OpenCart 3 Database
Put OpenCart into maintence mode.
Create a new database on your new host and import your OpeCart database backup.
Upload your PrestaShop site’s files and folders to the new host.
Update config.php to reflect the new database connection details and the full paths.
Update your admin/config.php to reflect the new paths/database details.
Update nameservers on domain to point to new host.
OPENCART DETAILED GUIDE
OpenCart is a very popular ecommerce system used worldwide and due to its great features, it’s easy to see why. However, if you are reading this guide it is likely that your host is not running OpenCart to its full potential. Whether that is due to downtime or speed issues, moving to a new server is often the best course of action. Whilst this can seem daunting, it’s actually quite simple to do when someone explains it in detail.

So if you’re looking to move your OpenCart site to a new host, the below guide will take you through all the steps in fine detail ensuring no matter how technical minded you are, you can escape your current hosting!

Ok, let’s begin.

BACK UP
It’s always wise to make a back up. If anything goes wrong and you don’t have a backup, you will be in trouble and could end up being left with a non functioning website (costing you time and money to repair).Whilst most hosts offer a 1 click backup system, we would always recommend doing the below as well. This will ensure you have a full backup so if anything does go wrong, you can restore the site quickly.

BACK UP YOUR OPENCART FILES
The first step is to back up your OpenCart files. To do this you will need a FTP program. Don’t worry if you have not heard of FTP before as we will guide you on how to use a popular (free) FTP program called FileZilla.

You can download FileZilla for free from https://filezilla-project.org

Once you have downloaded and installed FileZilla, you will need to your old host’s FTP login details. Usually these can be found in your original welcome e-mail from your host or in your hosting’s control panel. You will need the following FTP details:

  1. FTP host
  2. FTP username
  3. FTP password
  4. FTP port (usually 21).

If you are unable to locate these, copy and send the below message to your old host.

Hello, can you please confirm my FTP login details for my hosting? I need the FTP host, username, password and port.
Before you start backing up the website, you will need to create a new folder on your computer to store the OpenCart backup in. In this guide we will call this folder “OpenCart backup”. You can call it anything you wish but you may find the guide easier to follow if you call yours the same.

Once you have the FTP details and have created your OpenCart backup folder, open up FileZilla and enter the FTP details into the box at the top, then click the ‘QuickConnect’ button.

FTP old opencart host

Once connected, you will need to locate two folders.

The first is a public folder (this is usually called public_html or htdocs), the second is the storage folder. If OpenCart has been installed correctly you should see both of them at this point. You may also see other folders but these will not be required.

opencart public_html and storage folder

Next, in the left hand pane locate your “OpenCart backup” folder and open it.

opencart backup folder

Now you can start the backup downloading. To do this, select the public folder and the storage folder on the right hand pane, right click on them and select ‘Download’. Alternatively, you can drag them from the right and into your ‘OpenCart backup’ folder which will do the same thing.

download the opencart files and folders

You should now see your OpenCart files and folders being downloaded at the bottom.

Downloading Opencart files/folders

Once complete, you can close FileZilla as you now have a backup of your OpenCart 3 files and folders.

TIP : Should any files or folders fail to download, they will be listed in the failed transfers tab where you can then requeue the files for download again.
PUT OPENCART 3 INTO MAINTENANCE MODE.
Before you backup your database, you need to put OpenCart 3 into maintenance mode. When a customer purchases an item, the sale is recorded in the database (as well as lots of other data). If you skip this step, customers could still place orders on your website and in turn these orders would not be included in the database back up. By putting the site into maintenance mode, no additional orders can be placed and the database backup you will use to restore your site will not have any missing orders.

Open up your OpenCart 3 admin and click the system menu link on the left.

opencart admin system

Click the ‘settings’ link.

opencart 3 settings

Click the ‘edit’ button next to your store.

edit store

Select the server tab at the top.

server link

Next to the words ‘Maintenance Mode’ you should see a ticket box. Click ‘yes’ then click the save button at the top.

Maintenance Mode

Your website will now stop any orders from being placed ensuring the backup you take in the next stage contains all the relevant orders.

BACKING UP YOUR OPENCART 3 DATABASE.
Whilst you should now have a backup of your OpenCart files, the database is the brain behind your website. This is where all your orders, products and customers data is stored. To back up your database, you will need access to PhpMyAdmin. Virtually all hosts provide this feature and it usually shows up in your hosting control panel (look for a MySql databases icon).

Once you have located this, open it up and select your OpenCart database from the left (if it has not already been selected).

TIP : If you are not sure what your opencart database is called, open the file called config.php (in your backup from the last step) and look for the line “define(‘DB_DATABASE’, ‘ZZZ’);”. “ZZZ” will be the name of your database.
Select opencart database

You should now see a list of tables such as “oc_address”, oc_api” and “oc_cart”. There may be a lot of tables depending on how many plugins/modules you have installed.

Click the “Export” tab at the top of the page.

export opencart database

Finally, click the ‘Go’ icon to start your OpenCart database export and save the file to your computer.

go export

TIP : If you have a large database, you may find it easier to download it compressed. To do this, click the ‘custom’ tab then select “zipped” from the compression dropdown (then click go at the bottom).
RESTORE THE DATABASE ON YOUR NEW HOST
Now that you have a full backup of your OpenCart website, you can start the steps to restore this on your new hosting company. The first step is to restore the database. To do this, you will need to create a new database with your new host and access it via PhpMyadmin. Usually you can do this yourself via the hosting control panel but if you get stuck, contact your new host for details.

When you create your new host, you will need to make a note of:

  1. The database host
  2. The database username
  3. The database password.
  4. The database name.

as you will need these later on.

Open the new database in PhpMyAdmin and if it has not already been selected, click your database name from the left menu.

new opencart database

Click the “import” tab at the top.

import opencart database

Click the “choose File” button and select the OpenCart 3 database backup you made earlier.

choose opencart database file

Then click the ‘Go’ button at the bottom to start the import.

Go import

Once complete, you should see the message “Import has been successfully finished”.

Import has been successfully finished

You can now close PhpMyAdmin as your opencart database has been restored.

UPDATING YOUR OPENCART 3 CONFIG.PHP FILE
OpenCart 3 has two config.php files that you will need to update. These files contain important information that if incorrect will result in your OpenCart website not loading correctly (or at all).

Before you move on to editing these, ask your new host for the full path including the public folder (they will know what this means). Often, this can be found in your host’s support database and will look something like the below:

/home/sites/domain.co.uk/public_html/

then enter this in the box below but remove ‘/’ at the end (if you have one):

replace with your full path
Important : Make sure to not include any spaces and do not enter a trailing / (e.g. enter /something/something not /something/something/). Do not skip entering your full path into this box as without this, the below will not work.
By entering the path in the box above, our website can calculate some of the config file changes for you to make it easier.

In your “OpenCart Backup” folder, open your public folder (usually public_html or htdocs) and find the config.php file. Open this file with a plain text editor (such as Microsoft notepad or Notepad++) and locate the line:

define(‘DIR_APPLICATION’, ‘MMMMMM’);
(yours will have something other than MMMMMM) and change this to

define(‘DIR_APPLICATION’, ‘/catalog/’);
Next locate the line:

define(‘DIR_SYSTEM’, ‘NNNNNN’;
(yours will have something other than NNNNNN) and change this to

define(‘DIR_SYSTEM’, ‘/system/’);
Next locate the line:

define(‘DIR_IMAGE’, ‘OOOOOO’;
(yours will have something other than OOOOOO) and change this to

define(‘DIR_IMAGE’, ‘/image/’);
Next locate the line:

define(‘DIR_STORAGE’, ‘PPPPP/storage/’;
(yours will have something other than PPPPP)

You now need to replace the ‘PPPPPP’ text with your your full path () minus the public folder (usually called public_html or htdocs). For example if your full path was “/home/sites/domain.co.uk/public_html/”, you would need to remove the “/public_html/” bit at the end. Make sure to leave the /storage/ text.

Whilst still in the config.php file you should see some MySQL database connection details. These will need to be edited to match the details of the new database that you set up earlier.

locate the line:

define(‘DB_HOSTNAME’, ‘QQQQQQ’);
(yours will have something other than QQQQQQ) and change the QQQQQQ to your database host (usually localhost).

Next locate the line:

define(‘DB_USERNAME’, ‘RRRRRR’);
(yours will have something other than RRRRRR) and change the RRRRRR to your database username.

Next locate the line:

define(‘DB_PASSWORD’, ‘SSSSSS’);
(yours will have something other than SSSSSS) and change the SSSSSS to your database password.

Finally, locate the line:

define(‘DB_DATABASE’, ‘TTTTTT’)
(yours will have something other than TTTTTT) and change the TTTTTT to your database name.

It is usually not necessary to change the remaining database connection details but if you get any database connection error messages once the site is live, double check all the above and if that doesn’t work, contact your host to check the remaining database settings.

Once you have made the above changes, save and close the file.

UPDATING YOUR OPENCART 3 ADMIN/CONFIG.PHP FILE
Important : Before proceeding, make sure you entered your full path into the box in the last step (otherwise the below will not work).
OpenCart has two config.php files, one in the public folder (which you have just edited) and one in the admin (which you will edit in the next steps). Whilst these may look the same they are not and as such do not be tempted to copy the contents of one file into the other.

In your “OpenCart Backup” you should see a folder called ‘admin’ (unless you have changed this to something else in the past). Open this folder and you should see the other config.php file. Open this (again with a plain text editor).

locate the line:
define(‘DIR_APPLICATION’, ‘UUUUUU’);
(yours will have something other than UUUUUU) and change this to

define(‘DIR_APPLICATION’, ‘/catalog/’);
Next locate the line:

define(‘DIR_SYSTEM’, ‘VVVVVV’;
(yours will have something other than VVVVVV) and change this to

define(‘DIR_SYSTEM’, ‘/system/’);
Next locate the line:

define(‘DIR_IMAGE’, ‘WWWWWW’;
(yours will have something other than WWWWWW) and change this to

define(‘DIR_IMAGE’, ‘/image/’);
Next locate the line:

define(‘DIR_STORAGE’, ‘XXXXXX/storage/’;
(yours will have something other than XXXXXX)

You now need to replace the ‘XXXXXX’ text with your your full path () minus the public folder (usually called public_html or htdocs). For example if your full path was “/home/sites/domain.co.uk/public_html/”, you would need to remove the “/public_html/” bit at the end. Make sure to leave the /storage/ text.

Whilst still in the config.php file you should see some MySQL database connection details. These will need to be edited to match the details of the new database you set up earlier.

locate the line:

define(‘DB_HOSTNAME’, ‘YYYYYY’);
(yours will have something other than YYYYYY) and change the YYYYYY to your database host (usually localhost).

Next locate the line:

define(‘DB_USERNAME’, ‘ZZZZZZ’);
(yours will have something other than ZZZZZZ) and change the ZZZZZZ to your database username.

Next locate the line:

define(‘DB_PASSWORD’, ‘AAAAAA’);
(yours will have something other than AAAAAA) and change the AAAAAA to your database password.

Finally, locate the line:

define(‘DB_DATABASE’, ‘BBBBBB’)
(yours will have something other than BBBBBB) and change the BBBBBB to your database name.

That’s all the changes that are required. Save then close the file.

UPLOADING YOUR OPENCART 3 SITE TO THE NEW HOST.
Now that you have updated both the OpenCart 3 config.php files, you can upload your files/folders from your “OpenCart Backup” folder to your new hosting. Contact your new host and ask them for the following:

1) FTP host.
2) FTP username.
3) FTP password.
4) FTP port.

Once you have these, open up FileZilla again and enter them in the boxes at the top.

ftp new opencart host

You should now see your public folder (usually called public_html or htdocs) on the right hand side. At this stage, you do not open the public folder. Instead, make sure you open the folder 1 level higher in the directory tree. For example, in the below image you can see the public_html folder has a dotted line coming off to the left of it (shown larger in red). Follow that line and where it meets a folder, click that folder. This is because the ‘storage’ folder needs to be uploaded outside the public folder (not inside it).

directory tree

On the left hand pane, locate your “OpenCart backup” folder and open it.

opencart backup

You can now upload your ‘storage’ folder. To do this, right click on the ‘storage’ folder and select “Upload”.

upload storage folder

You should now see a list of files being uploaded at the bottom of your screen.

upload storage folder opencart

Once all of the storage folder has been uploaded, you can move on to restoring the core opencart files/folders from your backup. On the right hand side you should see your public folder (usually called public_html or htdocs). Open this folder and check to make sure it is empty. If it isn’t, download a copy of the files then delete them from the hosting.

new host public_html

Next, open the public folder inside your OpenCart back up.

opencart public_html folder

You should now see all of your opencart files and folders on the left and have the public folder open with your new host on the right.

Select all of your opencart files and folders on the left, right click on them and then select upload. Alternatively, you can drag all the files and folders over onto the public_html folder.

upload opencart public_html

You should now see your OpenCart public files/folders now being uploaded at the bottom.

opencart uploading

Once the upload has completed, check the failed transfers tab at the bottom for any files/folders that failed to upload. If any are listed, upload them again.

CHANGE YOUR NAMESERVERS
The next step is to change your domain’s nameservers to point to your new hosting company. This step can vary depending on the domain registrar you are using (the company who you renew your domain name with). As such, it is not possible for us to cover it in this guide but in brief do the following:

1) Contact your new host and ask them for their nameservers.
2) Contact your domain registrar and ask them to either change the nameservers on your domain to the ones your new host provided or explain how you can do this yourself.

Once the nameservers have been updated, allow 8 hours for them to fully propagate online.

TAKE YOUR OPENCART SITE OUT OF MAINTENANCE MODE.
Finally, log into your opencart website with your new host and turn off the maintenance mode you switched on before.

That’s it, your site should now be up and running on your new host.

Posted in Non classé, Opencart, WebTags:
Write a comment