It has never been essential for merchants to have an online ordering platform than when going cashless became extremely important. For a company to completely change its brick-and-mortar way of meeting with customers and doing business to a completely different virtual store online, it is expected that most business persons can find it confusing, nerve wracking, challenging and completely difficult in some cases.

Thanks to the brilliant and amazing opensource community which continues to change lives and contribute immensely to the entire globe, businesses, start-ups and SME’s can jump on simple solutions to completely transform their way of doing business. One such amazing solution is OpenCart.

Opencart is an easy-to-use, powerful, Open Source online store management program that can manage multiple online stores from a single back-end administrative area by simply filling in forms and clicking “Save”. There are many professionally-written extensions available to customize the store to your needs. Source: About OpenCart.

Features of OpenCart

  • Administrator Dashboard: All the important information available at a glimpse.
  • User Management: OpenCart allows you to set advanced user privileges and separate access for user groups and users.
  • Multi-Store: Manage multiple stores from one admin interface.
  • Options, attributes: No matter the case OpenCart offers a solution on adding extra important product variables.

Installing OpenCart on Ubuntu 20.04

In order to setup Open Cart, there are some minimum requirements your server needs to meet so that it can be installed and work properly. They include:

  • Web Server
  • PHP (at least 5.4)
  • Curl enabled
  • Database (MySQLi suggested)

Now that we know what we need, let us proceed to install OpenCart:

Step 1: Update and install essential tools

Once in the terminal of your fresh Ubuntu server, update it and install esential tools we shall use in our installation process

sudo apt update && sudo apt upgrade
sudo apt install vim git unzip curl -y

Step 2: Install and setup database

We are going to use MariaDB for this setup. Fortunately, we have a detailed guide already to get MariaDB 10.5 installed. Check out How To Install MariaDB on Ubuntu 20.04 (Focal Fossa)

After you have the database installed, the next step is to create a database and user for OpenCart as it can be anticipated. Proceed as illustrated below. Note that you are free to name your database and user differently and ensure you use a safe password.

$ mysql -u root -p
Enter password: 

MariaDB [(none)]> CREATE DATABASE opencartdb;
MariaDB [(none)]> CREATE USER 'opencartuser'@'localhost' IDENTIFIED BY 'StrongPassword';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON opencartdb . * TO 'opencartuser'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;

Step 3: Install and configure a web server and PHP

In order to get OpenCart served, it is a requirement that a web server be present. Here, you have the freedom of either picking Apache or Nginx. We shall use Nginx for this guide. Additionally, OPenCart requires PHP and therefore we will have to set it up as well. We have a complete guide that covers the installation of Nginx and PHP-FPM on Ubuntu 20.04. Kindly follow it then proceed to the next step.

Add recommended PHP Settings

Open up your php-fpm ini file and add/edit the details shown below. They include Timezone, and memory limit settings. Add your date.timezone (at about line 955) and change memory_limit (at about line 400) to 512MB.

$ sudo vim /etc/php/7.4/fpm/php.ini

memory_limit = 512M

[Date]
date.timezone = Africa/Nairobi

Check if php-fpm is running.

$ sudo systemctl status php7.4-fpm

● php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php7.4-fpm.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2020-08-05 20:20:57 UTC; 2min 13s ago
       Docs: man:php-fpm7.4(8)
    Process: 20536 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/7.4/fpm/pool.d/www.conf 74 (>
   Main PID: 20518 (php-fpm7.4)
     Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
      Tasks: 3 (limit: 2319)
     Memory: 9.3M
     CGroup: /system.slice/php7.4-fpm.service
             ├─20518 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
             ├─20534 php-fpm: pool www
             └─20535 php-fpm: pool www

Step 4: Clone OpenCart’s files from git and configure Nginx

The root directory is the folder our Webserver will check out for OpenCart’s files and serve them upon request. You can create a different one according to your needs.

sudo mkdir /var/www/html/commerce/ && cd /var/www/html/commerce/
sudo git clone https://github.com/opencart/opencart.git

A new directory inside /var/www/html/commerce called opencart will be created and files copied into it from OpenCart’s GitHub repository.

After cloning the files, navigate to upload and upload/admin directories and rename config-dist.php to config.php and admin/config-dist.php to admin/config.php

$ cd /var/www/html/commerce/opencart/upload/
$ sudo mv config-dist.php config.php

##Then..

cd /var/www/html/commerce/opencart/upload/admin
sudo mv config-dist.php config.php

Configure Nginx

We have to make a few changes to the Nginx configuration defaults by adding the details we need to serve OPenCart. Change into sites-enabled, back up the default file and create a new one with new configurations.

cd /etc/nginx/sites-enabled/
sudo mv default /tmp

Create a new file and add the details shown below. If you have an FQDN, replace example.com with it.

$ sudo vim /etc/nginx/sites-enabled/opencart.conf

server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  example.com;
        root         /var/www/html/commerce/opencart/upload;
        index index.php index.htm index.html;

        location / {
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ .php$ {
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_read_timeout 240;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_split_path_info ^(. .php)(/. )$;
        }
}

Change OpenCart’s files permissions

In order for Nginx to read the files, we have to grant it correct rights and the right permissions. Issue the commands below to get that done then restart Nginx and php-fpm.

sudo chown -R www-data:www-data /var/www/html/commerce/
sudo chmod -R 755 /var/www/html/commerce/
sudo systemctl restart nginx php7.4-fpm

Step 5: Complete OpenCart Setup via Web Interface

To complete setting up OpenCart, point your browser to the IP or domain name of the webserver serving the files. [http://[ip-or-domain-name]. You should get a page like below

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/OpenCart-page-1-license-1024×460.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="415" src="data:image/svg xml,” width=”926″>

License agreement

It begins with license agreements which you should accept before proceeding to the next step. Kindly do click on “Continue” on the page above

Pre-Installation

The next page checks if your server is set-up correctly. Ensure that “Current Settings” on each table matches the “Required Settings“. Additionally, ensure that the files /var/www/html/commerce/opencart/upload/config.php and /var/www/html/commerce/opencart/upload/admin/config.php are writable. Once you have confirmed everything is fine, scroll down and click “Continue

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/OpenCart-page-2-server-check-1024×501.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="450" src="data:image/svg xml,” width=”921″>

Enter your database and administration details

In the next page that shows up, you will be presented with a form for you to fill in the Database details we created in Step 2. You will notice a section that asks for your Admin credentials. Fill it up with your preferred username and password. After you have filled it up correctly simply click on “Continue” below the page.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/OpenCart-page-3-database-details-1024×506.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="464" src="data:image/svg xml,” width=”940″>

Installation complete

If everything went well, you should see “Don’t forget to delete your installation directory!” message displayed. You can go ahead and delete the directory. And our set up is finally complete!! Click on “Login to your Administration” to start customizing the backend of our first site.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/OpenCart-page-4-installation-complete-1024×524.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="487" src="data:image/svg xml,” width=”952″>

Step 6: Getting Started with OpenCart on Ubuntu 20.04

There are a number of steps required after installing OpenCart to get started selling from your online store. An OpenCart store is comprised of a Frontend and Admin interface. This Step will primarily focus on Admin interface functions and settings. These settings should be tested on the frontend before your site is launched. We already have admin login credentials and are able to login to our store’s Admin interface via http://server-ip-or-domain-name/admin as redirected from the previous step.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/OpenCart-page-5-admin-login-1024×498.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="460" src="data:image/svg xml,” width=”948″>

Once logged in, you might be asked to move the storage directory out of the public folder. Simply click “Move” and you will be sorted. The dashboard should come into view after that.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/OpenCart-page-6-admin-login-move-storage-1024×442.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="408" src="data:image/svg xml,” width=”947″>
<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/OpenCart-page-7-dashboard-1024×480.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="443" src="data:image/svg xml,” width=”945″>

General Settings

Under System > Settings, you will need to set your store’s name, owner, address, email, and phone number. Click on “edit” icon to start editing these settings. After you are done, click on the save icon to persist your settings.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/OpenCart-page-8-settings-store-edit-1-1024×473.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="433" src="data:image/svg xml,” width=”939″>
<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/OpenCart-page-9-general-settings-1024×480.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="441" src="data:image/svg xml,” width=”941″>

Store Settings

Under Store Settings, we will change from the default settings of “Your Store“, etc., to our actual Store Name and a description of the same for search engines. After you are done, click on the save icon to persist these settings.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/OpenCart-page-10-general-shop-1024×482.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="445" src="data:image/svg xml,” width=”946″>

Local Settings

Local Settings allow you to choose the Country that your store is operating from. After you are done, click on the save icon to persist the settings.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/OpenCart-page-11-general-local-1024×478.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="444" src="data:image/svg xml,” width=”952″>

Image Settings

Next, you will need to select a logo for your store and upload it via the Image Settings tab.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/OpenCart-page-11-2-general-image-1024×478.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>

To fully customize your site, follow the instructions on the other tabs (image,mail,server) in a similar manner as we ave done on the rest of the tabs.

To view your customized site, simply point your browser to http://server-ip-or-domain-name URL.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/OpenCart-page-12-final-site-1024×531.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>

Concluding Remarks

There is much more that you can do to make your online store as awesome as you would like it to be. You can integrate it with available payment gateways, change its look and feel controlled by modules and themes, Inventory Management, Tax options by default etc. A quick and keen look at its Official Documentation will attract a better understanding of this amazing e-commerce platform.