Important Steps After an OpenCart Installation

One of the limitations of Open Source shopping carts is that access to the core code is possible and this creates a problem as everyone can understand how the application works and that in itself create a security problem. It is therefore important to adopt some measures that can address these problems. In OpenCart e-commerce, there are some important steps that are necessary after installation to give additional security to the shopping cart. Critical among them are these two steps below:

  1. After installation, you should remove the /install/ directory immediately. You can do this through any FTP program.
    2. Change the file permissions for the config.php file in both the root directory and the /admin/ directories to 444.

    Once you have done that, you still need to take additional steps which are listed below:

 

1. Rename the admin folder in OpenCart


Renaming the admin folder in OpenCart is one way to secure your OpenCart e-commerce website. Because OpenCart is an open source software, it can be a target for hackers since they already know the basic file structure and how the core code works. Renaming the /admin/ folder is a good way to keep your OpenCart website safw. This will 'hide' the folder from scripts and hackers specifically looking for the 'admin' folder of OpenCart. The following steps will guide you on how to successfully change the /admin/ folder name in OpenCart.

  • Log into cPanel
  • Click on File Manager
  • Use file manager to navigate to the folder containing the “admin” folder
  • Click to highlight on the “admin” folder and select “rename”
  • Type in your new name for the “admin” folder (you can change it to whatever you want but the more obscure the name the better such as “ADMIN0028”)

Now, open the /admin/config.php with the code editor (Remember, you changed the name of the folder. Replace 'admin' with the new folder name).

Important! There are several instances of "admin" throughout the config file. All instances must be changed for this to work.

Below in Red are the instances of admin you will need to change.

// HTTP
define('HTTP_SERVER', 'http://test.domain.com/opencart/admin/');
define('HTTP_CATALOG', 'http://test.domain.com/opencart/');

// HTTPS
define('HTTPS_SERVER', 'http://test.domain.com/opencart/admin/');
define('HTTPS_CATALOG', '>http://test.domain.com/opencart/');

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

// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'userna5_ocar341');
define('DB_PASSWORD', 'password');
define('DB_DATABASE', 'userna5_ocar341');
define('DB_PREFIX', 'oc_');

There should be 5 instances referencing the /admin/ folder that would need to be updated to the new name you changed the folder to

These are important steps necessary to secure your OpenCart installation.

Further reading:

How to Manage Products and Categories in OpenCart

How to install OpenCart on a live server

How to install an Opencart template

How to manage extensions and themes in OpenCart

How to manage payments and shipping in OpenCart

OpenCart 2 Marketing and Affiliate Program

OpenCart Configuration Tutorial

OpenCart Maintenance Tutorial

OpenCart installation tutorial

 

2. Reset the admin password in OpenCart

Resetting the backend admin password will be something you will often do with your OpenCart store. It is possible that you will forget the password or you want to strengthen the password or you just want to change it after giving it out to someone else. There will always be some need to change this very important password.

The following tutorial will take you through how to change your admin password in OpenCart.

Log into cPanel and click on phpMyAdmin
Open the database that is connected to your OpenCart store.
Find the "user" table
Edit the user with the username "admin" and change the password field to 5f4dcc3b5aa765d61d8327deb882cf99. This string or hash changes the password to "password" (without the quotes)
Click "Go"

Now, attempt to log into the OpenCart Dashboard with your new password

You will need to change the password to a strong once you login to your OpenCart admin area.one as soon as possible.

 

3. Optimize an Opencart website for search engines


Search Engine Optomization is key to online business success. It is actually of no use for a website to be so great in layout and view yet, does not get to be seen by internet users. Search engine optimization helps address this problem. In this tutorial, we will look at the basic optimization required for an opencart website.

There are numerous SEO techniques but we will focus on 5 items below:

Page URL
Page Title
Meta Description
Header H1 Tag
Page Content (page description)

1.Page Title

The page title is the most important aspect of search engine optimization and can be the most important place to include keywords. Search engines place more importance on keywords in the title tags than the majority of other elements within a page. A well optimized title tag should include the target keywords while also influencing the searcher to click to the page from the search results.

Good Keyword: It’s best to use your most important keywords in the beginning of the title tag. Search engines place more weight on keywords at the beginning which can have a stronger impact on your rankings.

Length - Try to keep title tags between 10 - 60 characters since anything longer will get cut off on the search engine results page.
Branding - It’s generally a good idea to include your website name at the end of the title tag for additional brand exposure.

To add Title tags for OpenCart page, please go to:

Category Pages: Admin Home -> Catalog -> Categories -> General -> Meta Tag Title Field
Product Pages: Admin Home -> Catalog -> Products -> General -> Meta Tag Title Field

2. Page URL

page url

It’s important to include the main keyword in the page URL. Luckily OpenCart makes it easy to add the target keywords in the URL. Don’t worry about fitting in all the different keywords you identified. Trying to “over optimize” and stuff in excessive keywords can negatively impact rankings. Instead, focus on the main keyword.

To add SEO keyword for category and product, please go to:

Category Pages: Admin Home -> Catalog -> Categories -> Data -> SEO Keyword Field
Product Pages: Admin Home -> Catalog -> Products -> Data -> SEO Keyword Field

3. Meta Descriptions

To add a custom meta description to your OpenCart store, use the following navigational paths:

Category Pages: Admin Home -> Catalog -> Categories -> (Category to Optimize) -> General -> “Meta Tag Description” Field
Product Pages: Admin Home -> Catalog -> Products -> (Product to Optimize) -> General -> “Meta Tag Description” Field

4. Header Tags

To modify header tags in OpenCart, please go to:

Category Pages: Admin Home -> Catalog -> Categories -> General -> Category Name Field
Product Pages: Admin Home -> Catalog -> Products -> General -> Product Name Field

5. Page Content

Content Length – Typically the more content you have on a page the better chance it has to rank higher. Instead aim for at least 150 words of content for category and product pages. Feel free to go past well past 150 words but keep in mind that a significant amount of content on category pages can push down the actual products on the page and negatively affect conversion rates.
How to use Keyword: It’s important to use your target keywords throughout the content. However, make sure that the content reads naturally and doesn’t come across as keyword stuffed. In SEO, if your pages are “over optimized” you risk losing rankings as a result of a penalty.

To add content to category and product pages in Opencart, please go to:

Category Pages: Admin Home -> Catalog -> Categories -> General -> Description Field
Product Pages: Admin Home -> Catalog -> Products -> General -> Description Field.

 

4. Ensure The Cache System is Enabled

Caching is an important factor for every website. Caching really helps offload the heavy lifting a web server has to do to serve thousands of requests if not millions concurrently. There are loads of options available nowadays that provide a performance boost to your web application, but the basic concept of caching remains the same.

The Purpose of Caching

Gone are the days when you just needed to build a static HTML website that contained a couple of pages and you were done. In that case, you didn’t have to worry about the concurrent requests and heavy traffic generated on your website, as it’s so much faster to send those static HTML pages compared to the dynamic web pages which take quite a bit of server resources to build themselves.

A typical dynamic page does a lot, from querying a database to fetching data from third-party service providers. It requires a lot to display a page which includes lots of information in different formats. Specifically, you can’t afford to query the database to fetch the same complex information for every request as the traffic increases. It’ll soon make your servers cramped for resources, and before you can do something they'll be gone!

So you need something in-between that speeds things up, and that’s where caching comes into the picture. The idea of caching is very simple—you store the calculated/formatted results somewhere and fetch them when needed so that you don’t have to always load all content along with plgins, components and modules each time there is a request.

Also, there are lots of options available for caching—memcached, Redis, Varnish, and more. You could use those as per your requirements, and sometimes the combination of multiple components also helps improve the performance exponentially.

We’ll use the latest version of OpenCart, so make sure that you’ve installed that to follow the code.

How Basic Caching Works in OpenCart

The caching library is provided in the core itself, so let’s straight away explore it. Go ahead and open the system/library/cache.php file in your favorite text editor.


<?php
class Cache {
private $cache;

public function __construct($driver, $expire = 3600) {
$class = 'Cache\\' . $driver;

if (class_exists($class)) {
$this->cache = new $class($expire);
} else {
exit('Error: Could not load cache driver ' . $driver . ' cache!');
}
}

public function get($key) {
return $this->cache->get($key);
}

public function set($key, $value) {
return $this->cache->set($key, $value);
}

public function delete($key) {
return $this->cache->delete($key);
}
}


Starting with the constructor, it initializes the cache driver passed in the constructor argument. If the class is available for the requested caching adapter, it’ll be initialized to the $this->cache property, otherwise it’ll exit with the error message. We’ll see the different caching adapters in the next section.

Also, there are three wrapper functions which are used to perform all the operations related to caching.

The get method is used to retrieve the value from the cache.


$this->cache->get($key);

The set method is used to store the value in the cache.


$this->cache->set($key, $value);

The delete method is used to delete the key/value mapping from the cache.


$this->cache->delete($key);

So it's really straightforward to use caching functions in your modules as well.

There are lots of places in the front-end where the data is fetched from the cache store. Let's list some of them:

latest products
bestseller products
list of manufacturers
list of countries
list of currencies
list of zones
store settings

In the case of file caching, you'll find all the cache files stored under the system/cache directory. Although OpenCart clears the cache at appropriate events, you could also clear these files manually to fetch the latest data.


Caching Adapters

There are three caching adapters available in the core of OpenCart—file, memcache, and apc. The default caching adapter used in OpenCart is file.

Here’s the snippet from index.php which initializes the $cache object with the default caching adapter.


// Cache
$cache = new Cache('file');
$registry->set('cache', $cache);

Unfortunately, there’s no configurable way that allows you to switch the caching adapter as it’s hard-coded. Having said that, you could use OCMOD to change the default caching adapter without altering the core file.

As the implementation of each caching adapter is almost the same, we’ll only look at one of the caching adapters to see what’s going on. Let’s take memcache, for example. Go ahead and open system/library/cache/mem.php. You could also explore the other two adapters file.php and apc.php in the same directory.


<?php
namespace Cache;
class Mem {
private $expire;
private $cache;

public function __construct($expire) {
$this->expire = $expire;

$this->cache = new \Memcache();
$this->cache->pconnect(CACHE_HOSTNAME, CACHE_PORT);
}

public function get($key) {
return $this->cache->get(CACHE_PREFIX . $key);
}

public function set($key,$value) {
return $this->cache->set(CACHE_PREFIX . $key, $value, MEMCACHE_COMPRESSED, $this->expire);
}

public function delete($key) {
$this->cache->delete(CACHE_PREFIX . $key);
}
}

Each caching adapter is defined under the “Cache” namespace to avoid conflicts.

Recall those methods that we discussed in the last section—they actually end up here. So, when you call the get method in the Cache class, it actually calls the get method defined in the actual adapter class—in our case it’s the Mem class.


That ia all. With these steps, you should be able to protect and speed up your OpenCart store.

 

Order OpenCart Web Hosting

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

How to install OpenCart on a live server

There are two major ways to install OpenCart on a live website. A live website here simply means...

How to install an Opencart template

Opencart is a well known ecommerce engine with loads of fantastic features. However to build a...

OpenCart Configuration Tutorial

The OpenCart software is one of the most easy-to-use opensource applications providing all core...

OpenCart Maintenance Tutorial

OpenCart is a leading e-commerce platform used by millions of websites. Like every other Content...

How to Manage Products and Categories in OpenCart

In this tutorial on managing your products and categories in OpenCart, we will cover the...

Powered by WHMCompleteSolution