Jminfotech Blog

JMInfotech / /Migrating OpenCart from Local to Hosting Server
9
November

Migrating OpenCart from Local to Hosting Server

Opencart, a robust e-commerce solution for Internet merchants with the ability to create their own online business and participate in e-commerce at a minimal cost. OpenCart is a turn-key ready "out of the box" shopping cart solution. You simply install, select your template, add products and you’re ready to start accepting orders.

It has order management and multiple payment gateways already built in and opencart provide lifetime free support and free software updates.

Here We Explain How to migrate your OpenCart installation from your local (development) server to your hosting server.

Let’s get started:

Step 1: Backup database from local server.

Step 2: Backup OpenCart shop folder from local server.

Step 3: Create and import database to hosting server.

Step 4: Copy OpenCart shop folder contents to server, where your domain points to.

Step 5: Update configuration files.
Here is the interesting part

In the root folder and admin folder of your newly copied OpenCart website, you will see that both have a config.php file. Open them both in your favorite code editor. Intially, this is what they might look like:
——————————————————–
<?php
// HTTP
define(‘HTTP_SERVER’, ‘http://localhost/merchant/’);
define(‘HTTP_IMAGE’, ‘http://localhost/merchant/image/’);
define(‘HTTP_ADMIN’, ‘http://localhost/merchant/admin/’);

// HTTPS
define(‘HTTPS_SERVER’, ‘http://localhost/merchant/’);
define(‘HTTPS_IMAGE’, ‘http://localhost/merchant/image/’);

// DIR
define(‘DIR_APPLICATION’, ‘C:\xampp\htdocs\merchant/catalog/’);
define(‘DIR_SYSTEM’, ‘C:\xampp\htdocs\merchant/system/’);
define(‘DIR_DATABASE’, ‘C:\xampp\htdocs\merchant/system/database/’);
define(‘DIR_LANGUAGE’, ‘C:\xampp\htdocs\merchant/catalog/language/’);
define(‘DIR_TEMPLATE’, ‘C:\xampp\htdocs\merchant/catalog/view/theme/’);
define(‘DIR_CONFIG’, ‘C:\xampp\htdocs\merchant/system/config/’);
define(‘DIR_IMAGE’, ‘C:\xampp\htdocs\merchant/image/’);
define(‘DIR_CACHE’, ‘C:\xampp\htdocs\merchant/system/cache/’);
define(‘DIR_DOWNLOAD’, ‘C:\xampp\htdocs\merchant/download/’);
define(‘DIR_LOGS’, ‘C:\xampp\htdocs\merchant/system/logs/’);

// DB
define(‘DB_DRIVER’, ‘mysql’);
define(‘DB_HOSTNAME’, ‘localhost’);
define(‘DB_USERNAME’, ‘root’);
define(‘DB_PASSWORD’, ”);
define(‘DB_DATABASE’, ‘merchant_db’);
define(‘DB_PREFIX’, ”);
?>

—————————————————————————
<h3>admin folder:</h3>
—————————————————————————
<?php
// HTTP
define(‘HTTP_SERVER’, ‘http://localhost/merchant/admin/’);
define(‘HTTP_CATALOG’, ‘http://localhost/merchant/’);
define(‘HTTP_IMAGE’, ‘http://localhost/merchant/image/’);

// HTTPS
define(‘HTTPS_SERVER’, ‘http://localhost/merchant/admin/’);
define(‘HTTPS_IMAGE’, ‘http://localhost/merchant/image/’);

// DIR
define(‘DIR_APPLICATION’, ‘C:\xampp\htdocs\merchant/admin/’);
define(‘DIR_SYSTEM’, ‘C:\xampp\htdocs\merchant/system/’);
define(‘DIR_DATABASE’, ‘C:\xampp\htdocs\merchant/system/database/’);
define(‘DIR_LANGUAGE’, ‘C:\xampp\htdocs\merchant/admin/language/’);
define(‘DIR_TEMPLATE’, ‘C:\xampp\htdocs\merchant/admin/view/template/’);
define(‘DIR_CONFIG’, ‘C:\xampp\htdocs\merchant/system/config/’);
define(‘DIR_IMAGE’, ‘C:\xampp\htdocs\merchant/image/’);
define(‘DIR_CACHE’, ‘C:\xampp\htdocs\merchant/system/cache/’);
define(‘DIR_DOWNLOAD’, ‘C:\xampp\htdocs\merchant/download/’);
define(‘DIR_LOGS’, ‘C:\xampp\htdocs\merchant/system/logs/’);
define(‘DIR_CATALOG’, ‘C:\xampp\htdocs\merchant/catalog/’);

// DB
define(‘DB_DRIVER’, ‘mysql’);
define(‘DB_HOSTNAME’, ‘localhost’);
define(‘DB_USERNAME’, ‘root’);
define(‘DB_PASSWORD’, ”);
define(‘DB_DATABASE’, ‘merchant_db’);
define(‘DB_PREFIX’, ”);
?>
———————————————————————–

In the example above we can see that the store used xampp and the folder that contained it was located at C:\xampp\htdocs\merchant. Also notice that the slashes are backwards (under //DIR block). This detail is especially important if you are transferring from public server to local. To complete the migration, simply change the directories of the constants defined in the configuration files such that it will look something like these:

root folder:
————————————————————————-
<?php
// HTTP
define(‘HTTP_SERVER’, ‘http://yourdomain.com/’);
define(‘HTTP_IMAGE’, ‘http://yourdomain.com/image/’);
define(‘HTTP_ADMIN’, ‘http://yourdomain.com/admin/’);

// HTTPS
define(‘HTTPS_SERVER’, ‘http://yourdomain.com/’);
define(‘HTTPS_IMAGE’, ‘http://yourdomain.com/image/’);

// DIR
define(‘DIR_APPLICATION’, ‘/home/your_hosting/public_html/merchant/catalog/’);
define(‘DIR_SYSTEM’, ‘/home/your_hosting/public_html/merchant/system/’);
define(‘DIR_DATABASE’, ‘/home/your_hosting/public_html/merchant/system/database/’);
define(‘DIR_LANGUAGE’, ‘/home/your_hosting/public_html/merchant/catalog/language/’);
define(‘DIR_TEMPLATE’, ‘/home/your_hosting/public_html/merchant/catalog/view/theme/’);
define(‘DIR_CONFIG’, ‘/home/your_hosting/public_html/merchant/system/config/’);
define(‘DIR_IMAGE’, ‘/home/your_hosting/public_html/merchant/image/’);
define(‘DIR_CACHE’, ‘/home/your_hosting/public_html/merchant/system/cache/’);
define(‘DIR_DOWNLOAD’, ‘/home/your_hosting/public_html/merchant/download/’);
define(‘DIR_LOGS’, ‘/home/your_hosting/public_html/merchant/system/logs/’);

// DB
define(‘DB_DRIVER’, ‘mysql’);
define(‘DB_HOSTNAME’, ‘localhost’);
define(‘DB_USERNAME’, ‘your_hosting_database_username’);
define(‘DB_PASSWORD’, ‘your_hosting_database_password’);
define(‘DB_DATABASE’, ‘your_hosting_database’);
define(‘DB_PREFIX’, ”);
?>
————————————————————————————–
Admin Folder
——————–
<?php
// HTTP
define(‘HTTP_SERVER’, ‘http://yourdomain.com/admin/’);
define(‘HTTP_CATALOG’, ‘http://yourdomain.com/’);
define(‘HTTP_IMAGE’, ‘http://yourdomain.com/image/’);

// HTTPS
define(‘HTTPS_SERVER’, ‘http://yourdomain.com/admin/’);
define(‘HTTPS_IMAGE’, ‘http://yourdomain.com/image/’);

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

// DB
define(‘DB_DRIVER’, ‘mysql’);
define(‘DB_HOSTNAME’, ‘localhost’);
define(‘DB_USERNAME’, ‘your_hosting_database_username’);
define(‘DB_PASSWORD’, ‘your_hosting_database_password’);
define(‘DB_DATABASE’, ‘your_hosting_database’);
define(‘DB_PREFIX’, ”);
?>
——————————————————————–

What’s changed here are the database parameters, the old root folder of the local server became that of the hosting server under the //DIR block, and of course the domain name.

Save the changes you made and you are done! No sweat!

If you are facing any difficult or any opencart project needs Please Contact Us Dont Forget to visit our Opencart Demo site

Leave a Reply

signup for newsletter