Sell And Buy

Thursday 12 March 2015

How to upload files and databases of opencart from local server to domain server

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

In /config.php and admin/config.php you need to change some variables to make the store re-install work. Open these files in notepad, dreamweaver or your preferred html/code editing application.
If you are uploading the copied site to a Directory you need to specify this in the following files:
  • admin/config.php
  • /config.php
Where ‘store’ is the new directory name. Where ‘user’ is your server account address. Where ‘yourdomainname.co.uk’ is the web domain of your new website.


























<?php
// HTTP
define('HTTP_SERVER', 'http://yourdomainname.com/admin/');
// HTTPS
define('HTTPS_SERVER', 'http://yourdomainname.com/admin/');
// DIR
define('DIR_APPLICATION', '/home/user/public_html/admin/');
define('DIR_SYSTEM', '/home/user/public_html/system/');
define('DIR_DATABASE', '/home/user/public_html/system/database/');
define('DIR_LANGUAGE', '/home/user/public_html/admin/language/');
define('DIR_TEMPLATE', '/home/user/public_html/admin/view/template/');
define('DIR_CONFIG', '/home/user/public_html/system/config/');
define('DIR_IMAGE', '/home/user/public_html/image/');
define('DIR_CACHE', '/home/user/public_html/system/cache/');
define('DIR_DOWNLOAD', '/home/user/public_html/download/');
define('DIR_LOGS', '/home/user/public_html/system/logs/');
define('DIR_CATALOG', '/home/user/public_html/catalog/');
// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'database_username');
define('DB_PASSWORD', 'newpassword');
define('DB_DATABASE', 'database_name');
define('DB_PREFIX', 'oc_');
admin/config.php
Where ‘store’ is the new directory name. Where ‘user’ is your server account address. Where ‘yourdomainname.com’ is the web domain of your new website.




























<?php
// HTTP
define('HTTP_SERVER', 'http://yourdomainname.com/admin/');
define('HTTP_CATALOG', 'http://yourdomainname.com/');
// HTTPS
define('HTTPS_SERVER', 'http://yourdomainname.com/admin/');
define('HTTPS_CATALOG', 'http://yourdomainname.com/');
// DIR
define('DIR_APPLICATION', '/home/user/public_html/admin/');
define('DIR_SYSTEM', '/home/user/public_html/system/');
define('DIR_DATABASE', '/home/user/public_html/system/database/');
define('DIR_LANGUAGE', '/home/user/public_html/admin/language/');
define('DIR_TEMPLATE', '/home/user/public_html/admin/view/template/');
define('DIR_CONFIG', '/home/user/public_html/system/config/');
define('DIR_IMAGE', '/home/user/public_html/image/');
define('DIR_CACHE', '/home/user/public_html/system/cache/');
define('DIR_DOWNLOAD', '/home/user/public_html/download/');
define('DIR_LOGS', '/home/user/public_html/system/logs/');
define('DIR_CATALOG', '/home/user/public_html/catalog/');
// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'database_username');
define('DB_PASSWORD', 'newpassword');
define('DB_DATABASE', 'database_name');
define('DB_PREFIX', 'oc_');

After we are done editing the config file we need to right click on config.php and select Set Permissions. We recommend setting the permissions of config.php to 444. This will make the file as read-only.
Next stop, we need to repeat the same procedure with admin/config.php file. We will find the file under admin/config.php. Again we will edit the database settings and change the permissions of the admin/config.php file to 444.
Go to your new site to see the result.

 

No comments:

Post a Comment