Migrating OpenCart from Local to Hosting Server

  • SumoMe

Today I will show you a simple tutorial on 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:

root folder:

<?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', '');
?>

admin folder:

<?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!

About maca

Hello, my name is Karlo Macariola. I once dreamed to be a painter or an animator but when I typed my first line of code I immediately fell in love with programming. Today my passions are with web development and web design though sometimes I still withdraw to my first love which is drawing. DeviantArt | Twitter | Facebook
This entry was posted in Web Development & Design and tagged , , . Bookmark the permalink.

38 Responses to Migrating OpenCart from Local to Hosting Server

  1. Babalonk27 says:

    /home/your_hosting/public_html/system/logs

    can you tell my please what I need to replace here?

    what is my “your_hosting”?

  2. Nauman says:

    Hey Mate,
    Thanks for the great tutorial….
    it help me in moving my website from local host.
    Thanks again.

  3. viggo says:

    Hi, thanks for the tutorial.
    I´m getting this error: Error: Could not load database file mysql!
    Any ideas how to fix this?

  4. paklah says:

    Thanks for your great tutorial…

  5. pianfian says:

    I have a problem “Error: Could not load database file mysql!” help me please?

  6. Godwin says:

    what this warning mean?

    Warning: require_once(home/test/public_html/system/startup.php) [function.require-once]: failed to open stream: No such file or directory in /home/test/public_html/admin/index.php on line 19

    Fatal error: require_once() [function.require]: Failed opening required ‘home/test/public_html/system/startup.php’ (include_path=’.:/usr/lib/php’) in /home/test/public_html/admin/index.php on line 19

    • Robbert says:

      Warning: require_once(home/test/public_html/system/startup.php) [function.require-once]: failed to open stream: No such file or directory in /home/test/public_html/admin/index.php on line 19

      Fatal error: require_once() [function.require]: Failed opening required ‘home/test/public_html/system/startup.php’ (include_path=’.:/usr/lib/php’) in /home/test/public_html/admin/index.php on line 19

      I also have this problem. please help me to solve this problem?

      • vijay says:

        Hi guys
        This warning and fatal error is due to path has been went wrong.u have to give the appropriate path in config.php. here in this article he mention “your_hosting” in the path location.that is meant to your hosting name after that you have to follow with the public_html.

  7. ziyaaf says:

    Thanks so much dude ! even opencart website didn’t provide a better solution. Saved me a lot of time 🙂

  8. Lukman says:

    Thanks, it’s great tutorial…

  9. This two files has screwd up my opencart installation. Now, I have to look at them one by one.

    Thank you very much mate for sharing.

    Cheer,
    Nyoman

  10. Pingback: Cara Upload Open Cart dari Localhost ke Server Online | Tapis Berseri [dot] Com

  11. ralph says:

    Hi, i followed your tutorial and still get this error message

    Warning: require_once(/home/http://awesomegiftsng.com/system/startup.php) [function.require-once]: failed to open stream: No such file or directory in /home/awesomeg/public_html/index.php on line 15

    Fatal error: require_once() [function.require]: Failed opening required ‘/home/http://awesomegiftsng.com/system/startup.php’ (include_path=’.:/usr/lib/php’) in /home/awesomeg/public_html/index.php on line 15

    pls help

    • Hello,
      Very good tutorial. Really helps me a lot. Many Thanks.
      The thing is that you need to upload all your local files to dev server may be in cPanel Or any other like if you upload it in Godaddy Hosting.

      Just change the path in both config.php ( at _root & inside the admin folder ) – make sure you have mentioned all DIR paths correctly. And put your DB info there. Nothing needed to change any where – just run your site in your web browser.
      Hope you enjoy!
      Thank You Maca for sharing your experience with us.

  12. Ahmed Khan says:

    Hello Maca.

    Thanks for the instructions. This is very helpful for those who dont know how to migrate their opencart website from a local server to a web server. Really appreciate your effort pal. Hope more people get benefited like me and be showing their appreciation to you.

    Keep coding.
    Ahmed Khan

  13. tara says:

    Hi i have moved from one server to the other. everything works fine on the new domain but for the images. Admin also works fine with the images, but the actual website images are not getting loaded. i have ensured images are there in the folder and config is pointed to there. please help. actually when i install new opencart installation on ipage(provider) using simplescript, i donot find images but ipage admin does some magic to get default images. now with my move of the website, they are unable to support it. do you have any idea how do go about doing this. please help. thanks in advance

  14. ikilaptop says:

    nice share… i followed your tutorial and suces thanks for share

  15. Arslan Qamar says:

    I am facing Problem opencart in localhost. I have installed new wamp server.
    Warning: require_once(D:\www\webdata/system/startup.php) [function.require-once]: failed to open stream: No such file or directory in E:\www\webdata\index.php on line 19

    any one tell me whats problem???

  16. venkatesh says:

    i have integrated with opencart source code but admin page nice working but user page this error will be display.

    Error: Could not load template catalog/view/theme/default/template/module/sidebarslideshow.tpl!

    kindly reply me the error how to clear it..

    thanks in advance..,

  17. meena says:

    Thanks so much! only logo and slideshow images are missing on my site after uploading it on server.. Please help!

  18. Jawad says:

    Hi , i am hosting my website on 000webhost.com/ and on the ftp server the files are in the directory root/public-html , is this what i should put instead of your_hosting ?

    • vijay says:

      hi jawad
      i am also having the same question.in free web hosting panel how to add “your_hosting” in the path?

  19. Simmy says:

    Hello Moca,

    I am a new hand for the opencart. Regarding your_hosting in the line /home/your_hosting/public_html refers to the path of your hosting account. Fore example: /home/mywebsite/public_html. Do you mean that I should replace your_hosting with my ftp address:ftp://simonhuang.us1.9fbbs.net (this is my ftp address) ? Please help me. Thank you in advance. Following is how I modify the code concerning this question but end up with failure.

    // DIR
    define(‘DIR_APPLICATION’, ‘/home/ftp.simonhuang.us1.9fbbs.net/public_html/test-site/admin/’);
    define(‘DIR_SYSTEM’, ‘/home/ftp.simonhuang.us1.9fbbs.net/public_html/test-site/system/’);
    define(‘DIR_DATABASE’, ‘/home/ftp.simonhuang.us1.9fbbs.net/public_html/test-site/system/database/’);
    define(‘DIR_LANGUAGE’, ‘/home/ftp.simonhuang.us1.9fbbs.net/public_html/test-site/admin/language/’);
    define(‘DIR_TEMPLATE’, ‘/home/ftp.simonhuang.us1.9fbbs.net/public_html/test-site/admin/view/template/’);
    define(‘DIR_CONFIG’, ‘/home/ftp.simonhuang.us1.9fbbs.net/public_html/test-site/system/config/’);
    define(‘DIR_IMAGE’, ‘/home/ftp.simonhuang.us1.9fbbs.net/public_html/test-site/image/’);
    define(‘DIR_CACHE’, ‘/home/ftp.simonhuang.us1.9fbbs.net/public_html/test-site/system/cache/’);
    define(‘DIR_DOWNLOAD’, ‘/home/ftp.simonhuang.us1.9fbbs.net/public_html/test-site/download/’);
    define(‘DIR_LOGS’, ‘/home/ftp.simonhuang.us1.9fbbs.net/public_html/test-site/system/logs/’);
    define(‘DIR_CATALOG’, ‘/home/ftp.simonhuang.us1.9fbbs.net/public_html/test-site/catalog/’);

  20. someone says:

    thank’s!
    very useful

  21. rifki says:

    how if i get

    Warning: mysql_connect() [function.mysql-connect]: Access denied for user ‘pushopp’@’localhost’ (using password: YES) in /home/pushopp/public_html/system/database/mysql.php on line 6
    Error: Could not make a database connection using pushopp@localhost
    Warning: mysql_close() expects parameter 1 to be resource, boolean given in /home/pushopp/public_html/system/database/mysql.php on line 67

    how to fix it?

  22. GREAT POST !!! .. i love your blog , the best for tutorial ..

  23. suresh says:

    hi any one please help me i got this type of error

    Warning: require_once() [function.require-once]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in D:\Hosting\11421805\html\glory\index.php on line 17

    Warning: require_once(http://www.surgicals.in/system/startup.php) [function.require-once]: failed to open stream: no suitable wrapper could be found in D:\Hosting\11421805\html\s\index.php on line 17

    Fatal error: require_once() [function.require]: Failed opening required ‘http://www.surgicals.in/system/startup.php’ (include_path=’.;C:\php\pear’) in D:\Hosting\11421805\html\s\index.php on line 17

  24. KornBread says:

    This was pretty straight forward. Thanks a mil bro!!!

  25. Paulo says:

    Hi guys

    I have this problem

    Warning: require_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/u920082339/public_html/index.php on line 17 Warning: require_once(http://vivantmusic.freeserver.me/system/startup.php): failed to open stream: no suitable wrapper could be found in /home/u920082339/public_html/index.php on line 17 Fatal error: require_once(): Failed opening required ‘http://vivantmusic.freeserver.me/system/startup.php’ (include_path=’.:/usr/lib/php’) in /home/u920082339/public_html/index.php on line 17

    someone can help me? please

  26. Paulo says:

    THANKS!!
    I could Resolve!!

    MACA thanks for this tutorial!!

    really good!

    vivantmusic.freeserver.me

  27. Roman says:

    Hi everybody.

    May I suggest alternative config.php file code:

    /* php-code */
    $host_path = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - strpos(strrev($_SERVER['SCRIPT_FILENAME']), "/"));
    $http_path = "http://" . $_SERVER['HTTP_HOST'] . substr($_SERVER['PHP_SELF'],0, strlen($_SERVER['PHP_SELF']) - strpos(strrev($_SERVER['PHP_SELF']), "/"));
    // HTTP
    define('HTTP_SERVER', ''.$http_path.'');

    // HTTPS
    define('HTTPS_SERVER', ''.$http_path.'');

    // DIR
    define('DIR_APPLICATION', ''.$host_path.'catalog/');
    define('DIR_SYSTEM', ''.$host_path.'system/');
    define('DIR_DATABASE', ''.$host_path.'system/database/');
    define('DIR_LANGUAGE', ''.$host_path.'catalog/language/');
    define('DIR_TEMPLATE', ''.$host_path.'catalog/view/theme/');
    define('DIR_CONFIG', ''.$host_path.'system/config/');
    define('DIR_IMAGE', ''.$host_path.'image/');
    define('DIR_CACHE', ''.$host_path.'system/cache/');
    define('DIR_DOWNLOAD', ''.$host_path.'download/');
    define('DIR_LOGS', ''.$host_path.'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', '');

    /* end-php-code */


    For instance:
    “$http_path” will print “http://localhost/”, (or http://path/to/…)
    and
    $host_path will print “C:/wamp/www/”, (or /home/your_hosting/public_html/path/to/…)
    I would be happy if that will help.

    • Amit Banerjee says:

      Its really great. when I try to upload in Client’s server it was not working, then I put your code and now it works fine.

  28. Qais says:

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /hermes/bosoraweb112/b883/ipg.besolvescom2/buyatleast.com/config.php on line 16

    I have receive above error after updating
    please help to remove this error

Leave a Reply to maca Cancel reply

Your email address will not be published. Required fields are marked *