OpenCart is one of the most popular e-commerce platform favoured by many individuals and small businesses. We have covered OpenCart store in several articles recently. For instance, since the release of OpenCart 2.0, we have post this step-by-step guide to upgrade OpenCart. If you do not have an OpenCart store yet, you can refer to following guide to get a fresh install: how to install OpenCart automatically? Today we will talk about how your installed and running OpenCart shops can be moved from one server to another, from one web hosting to another. The migration of OpenCart is easy overall.
How to Migrate OpenCart Store to New Hosting Server?
Before you even get into the details, take a look at the to-do list below. You can follow these steps one by one to move an OpenCart store to your new web host. If you thought you did something wrong somewhere during the OpenCart migrating process, you can also click the links below to quickly navigate to the specific part for more details.
- Step 1. Back up OpenCart from old server
- Back up web pages
- Back up database
Step 2. Upload Opencart to new server
- Upload web pages
- Restore database
Step 3. Edit OpenCart configuration files
- Edit config.php at root
- Edit config.php at admin folder
Step 4. Update domain for Opencart
- Add domain to new hosting server
- Change domain DNS
Now roll up your sleeves and begin to move your OpenCart to new hosting server.
Step 1. Back up OpenCart
OpenCart is database driven. You have to back up both your page files and the database. Web pages can be downloaded from your web server to your local machine through a FTP client or an online file manager. The OpenCart database can be backed up using phpMyAdmin which is offered for free by almost all PHP Linux hosting service providers.
Back up OpenCart Web Files
There are many FTP tools you can choose from. They are similar from each other. FileZilla is an open source FTP client that is cross-platform and totally free to download and use. Before you connect to your OpenCart server through FTP, you can actually compress the OpenCart installation folder in your web hosting control panel. After that you can just download one archived file through FTP other than downloading numerous files one by one. If you use a cPanel web hosting, such as Bluehost PHP Linux hosting, you can compress your website files through the File Manager and download files directly through your web browser.
Right click on the compressed OpenCart backup file, you will find the Download option to download a copy of your OpenCart site backup file right on your web browser.
Back up OpenCart Database
The back up of Open database is also very easy. You do not have to install any database management or backup tools. A decent web hosting should have such a tool built in their hosting control panel. As we mentioned above phpMyAdmin is such a tool for MySQL database management you will only need for OpenCart database backup and restore. We have a step-by-step guide here shows steps to back up MySQL database using phpMyAdmin.
Now you have successfully backed up your OpenCart store. It is just that easy. We have told you before. Now we get two files for the OpenCart shop, one database backup file, one compressed file which contains all the web pages. Continue with below steps to upload them from your computer to your new web host or new server.
Step 2. Upload Opencart to new server
Again we have to upload OpenCart web page files and database backup file separately through different tools.
Upload OpenCart web pages to new web server
Since you have already downloaded OpenCart web files from the old web host or server to your own computer through either a FTP software tool or your web browser, you should know how it works for file uploading to new web host or server too. Using the same tool, but with different direction, you can transfer or upload files from computer to remote server. Here are some tips to help you make things easier:
- Create a new folder on your web server specifically to save the OpenCart files. Use a descriptive name for this folder, such as OpenCart, Store. This can help you keep all files on the server well organized. It would be easier to back up and manage your files in the future. This is especially useful when you have multiple websites hosted under the same account. Note that some web hosting services accept multiple or unlimited sites under one hosting account. For example, you can refer to this guide to add additional websites to Bluehost for free.
- Upload the OpenCart zip file from computer to web server through FTP or your online File manager. If your new host offers cPanel as the web hosting control panel, you can use its File Manager to upload big file up to 50MB. If your OpenCart files are compressed and the archived file is larger than that, you should use a FTP client instead.
- Once the OpenCart zip file is uploaded to your new server, you can right click on it to unzip the file. cPanel and many other web hosting control panel solution should has this feature to help you zip and unzip files online.
Upload OpenCart database backup to new server
The database upload is a different from web page uploading from your computer to web server. Basically you need to create a new database on the new database server, then use a database management tool to restore the OpenCart database backup to the newly created database on server. Luckily web hosting service providers now allow you to easily create new MySQL databse in their control panel. See this guide to create MySQL database online. Now you can use the same database management tool which we have used to back up the OpenCart database to restore the backup to this newly created database. See this step-by-step guide to restore MySQL database.
Until now we have successfully moved the OpenCart website or store from the old web host or server to the new one. Since now the OpenCart migration becomes much easier and faster.
Step 3. Edit OpenCart configuration files
OpenCart store has two config.php files located in different folder. One can find at the root folder of your OpenCart store. The other one is situated at the ‘admin’ subfolder of your OpenCart installation directory. That’s to say, we need to edit the config.php and admin/config.php. These two files are similar. If you know how to edit one of them, follow the suit to edit the other one.
Right click on the config.php file within your hosting control panel, then edit it with the online file editor. See below figure.
The source code of OpenCart configuration file looks like below.
From the code, you can see it mainly consists of the HTTP, HTTPS, DIR and DB sections.
Edit OpenCart Domain
HTTP and HTTPS define your OpenCart domain or URL. If you do not plan to use a new domain for your OpenCart store, or move the installation to a different folder, leave both the HTTP and HTTPS unchanged. If you want to change a new domain, see this guide for more specific instructions to change OpenCart URL.
Edit OpenCart directory settings
The DIR section in OpenCart configuration file defines all kinds of directories for application, system, database, language, template and so on. You can find the file or directory path of your OpenCart installation in the File Manager of cPanel. Make the change accordingly.
Edit OpenCart database connection
You may not need to change some or any of the database entries lines if you created the new database with your new web hosting using the same name, password as the old database with your previous web hosting service provider. Otherwise, replace the corresponding fields of the database entries to connect your OpenCart store with the new database.
Make sure to edit the file permission of the configuration files to 644 or 444 so they are read-only.
Step 4. Update domain for OpenCart
Now your whole OpenCart files are relocated to the new home with your new web host or server. What you need to do now is to transfer OpenCart domain to new server as well. Unlike the web files migration from one old server to new server or the database transfer from one database server to another, you can simply edit the DNS records or name server with your domain registrar to point a domain from one server to another.
Firstly you need to add your domain to the hosting panel with your new web hosting or your new hosting account. Make sure to point the domain to the OpenCart installation folder on the new server. If you want to make sure everything is working well on the new hosting server, you can refer to this guide to emulate DNS change through Hosts file on PC. This simple trick can help you test your OpenCart shopping site on the new hosting server or account without changing DNS of your domain thus will not affect your current production site on your old web hosting server. When you have verified the OpenCart store works well on the new server, you can go to change the name servers of your domain so it redirects all your website visitors to the new server. This should be done with your domain registrar. There are two methods you can achieve that. You can choose to change name servers or change only DNS A records to point your domain to a new server. Let’s take GoDaddy for example, you can refer to this guide to change name servers with GoDaddy to point your domain to your new web host. This could take up to 48 hours to take effect. You can also refer to this guide to change DNS A records with GoDaddy to point your domain to new web hosting server. This change normally takes only couple of hours or less for DNS propagation. Once the change has populated over the internet, all your traffic and visitors will be taken to your new OpenCart server.
That’s should cover almost all the basics you should know about OpenCart store migration to new server. The OpenCart migrating may take a while depending on how many files you have, but it is not difficult overall. Please let us know if any questions in the comments section below.