OpenCart

OpenCart

OpenCart is an open-source PHP-based e-commerce platform used to create and manage online stores. OpenCart provides an easy-to-use solution for building e-commerce websites with comprehensive features such as product management, categories, payment systems, and order management.

OpenCart supports various plugins and themes that can be customized to meet business needs, and it includes multistore support, allowing users to manage multiple stores from a single admin dashboard. The platform is known for being lightweight, fast, and flexible, while also supporting various payment and shipping methods.

OpenCart is suitable for small to medium-sized businesses seeking a low-cost, highly flexible e-commerce solution without sacrificing features.

1. System Requirements

System requirements for running OpenCart v3.0:

  • Apache web server
  • PHP 8.0+
  • MySQL or MariaDB

Before starting the deployment, prepare the following:

  • A VPS or server with Ubuntu 24.04 LTS OS
  • SSH access to the server
  • A domain already pointed to the server

2. Server Preparation

Update the system

sudo apt update
sudo apt upgrade -y

Install Apache

sudo apt install apache2 -y

Install MariaDB

sudo apt install mariadb-server -y

Install the PPA ondrej/php repository.

sudo add-apt-repository ppa:ondrej/php -y
sudo apt upgrade -y

Install PHP 8.1 and the required extensions.

sudo apt install libapache2-mod-php8.1 php8.1 php8.1-common \
    php8.1-cli php8.1-gd php8.1-xml php8.1-mbstring \
    php8.1-mysql php8.1-curl php8.1-intl php8.1-zip -y

3. Create a Database

Log in to MariaDB.

sudo mysql

Create a database and user.

CREATE DATABASE opencart;
CREATE USER 'opencart'@'localhost' IDENTIFIED BY 'rahasia';
GRANT ALL PRIVILEGES ON opencart.* TO 'opencart'@'localhost';
FLUSH PRIVILEGES;
exit

4. Apache Configuration

Create a virtual host configuration for contoh.com.

sudo nano /etc/apache2/sites-available/contoh.com.conf	

Enter the configuration.

<VirtualHost *:80>
    ServerName www.contoh.com
    ServerAlias contoh.com
    DocumentRoot /var/www/contoh.com
    <Directory /var/www/contoh.com>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog /var/log/apache2/contoh.com_error.log
    CustomLog /var/log/apache2/contoh.com_access.log combined
</VirtualHost>

Enable the rewrite module, virtual host, and restart apache2.

sudo a2enmod rewrite
sudo a2ensite contoh.com
sudo systemctl restart apache2	

Install certbot

sudo apt install certbot python3-certbot-apache -y	

Request an SSL certificate.

sudo certbot --non-interactive \
    -m [email protected] \
    --agree-tos \
    --no-eff-email \
    --apache -d contoh.com -d www.contoh.com \
    --redirect	

5. Install OpenCart

Download OpenCart from GitHub.

wget https://github.com/opencart/opencart/releases/download/3.0.4.0/opencart-3.0.4.0.zip

Extract opencart-3.0.4.0.zip.

sudo apt install unzip -y
unzip opencart-3.0.4.0.zip

Copy the OpenCart configuration files.

cd upload
cp config-dist.php config.php
cp admin/config-dist.php admin/config.php

Move the directory to /var/www.

sudo mv ../upload /var/www/contoh.com

Change the user-group of the directory.

sudo chown -R www-data:www-data /var/www/contoh.com

Access https://www.contoh.com to install PrestaShop:

  1. License Agreement: Agree to the license terms, click Continue.
  2. Pre-installation: Check the requirements; if all are met, click Continue.
  3. Configuration: Enter the database connection details and admin account information, then click Continue.
  4. Installation Complete: Once the installation is finished, delete the install directory.
sudo rm -rf /var/www/contoh.com/install