Skip to content

Deploying OpenCart

Introduction

OpenCart is a popular open-source e-commerce platform that powers thousands of online stores worldwide. Built with PHP and using MySQL for data storage, OpenCart provides a robust shopping cart solution with an extensive marketplace of extensions and themes to customize your store.

Since its release in 2009, OpenCart has grown to become one of the most widely used e-commerce platforms, known for its ease of use, extensive features, and active community. The platform is suitable for small to large online retailers looking for a self-hosted solution.

Key features of OpenCart include:

  • Product Management: Unlimited products with options, attributes, and variants
  • Multi-Store: Manage multiple stores from a single admin panel
  • Payment Gateways: Support for PayPal, Stripe, Square, and 50+ payment methods
  • Shipping Methods: Flexible shipping options with rate calculations
  • Tax Management: Configure tax rules for different regions
  • Customer Management: Customer accounts, groups, and order history
  • SEO Friendly: SEO URLs, meta tags, and sitemap generation
  • Extension Marketplace: Thousands of free and premium extensions
  • Theme System: Customizable themes and templates
  • Multilingual: Support for multiple languages and currencies
  • Reports: Sales, product, and customer analytics
  • Affiliate System: Built-in affiliate program management

This guide walks through deploying OpenCart on Klutch.sh using Docker.

Why Deploy OpenCart on Klutch.sh

Deploying OpenCart on Klutch.sh provides reliable e-commerce infrastructure:

No Transaction Fees: Unlike hosted platforms, no per-sale fees beyond payment processing.

Full Control: Complete control over your store’s code and data.

Persistent Storage: Store products, orders, and customer data with persistent volumes.

HTTPS by Default: Secure checkout with automatic SSL certificates.

Scalable Resources: Handle traffic spikes during sales and promotions.

Custom Domains: Use your business domain for professional branding.

Prerequisites

Before deploying OpenCart on Klutch.sh, ensure you have:

  • A Klutch.sh account
  • A GitHub account with a repository for your deployment
  • A MySQL or MariaDB database instance
  • Payment gateway accounts for processing transactions

Deploying OpenCart on Klutch.sh

    Set Up Your Database

    Deploy a MySQL or MariaDB database on Klutch.sh or use an external database service.

    Create Your Dockerfile

    Create a Dockerfile in your repository:

    FROM php:8.1-apache
    # Install PHP extensions
    RUN apt-get update && apt-get install -y \
    libpng-dev \
    libjpeg-dev \
    libfreetype6-dev \
    libzip-dev \
    unzip \
    curl \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install gd mysqli pdo pdo_mysql zip
    # Enable Apache modules
    RUN a2enmod rewrite
    # Download OpenCart
    WORKDIR /var/www/html
    RUN curl -L https://github.com/opencart/opencart/releases/download/4.0.2.3/opencart-4.0.2.3.zip -o opencart.zip \
    && unzip opencart.zip \
    && mv upload/* . \
    && rm -rf opencart.zip upload
    # Set permissions
    RUN chown -R www-data:www-data /var/www/html \
    && chmod -R 755 /var/www/html
    EXPOSE 80
    CMD ["apache2-foreground"]

    Push to GitHub

    Commit and push your Dockerfile to your GitHub repository.

    Create a New Project on Klutch.sh

    Navigate to the Klutch.sh dashboard and create a new project.

    Create and Configure the App

    Create a new app and connect it to your GitHub repository.

    Configure HTTP Traffic

    Set the traffic type to HTTP with an internal port of 80.

    Set Environment Variables

    Configure database connection:

    VariableDescription
    DB_HOSTNAMEDatabase host
    DB_USERNAMEDatabase user
    DB_PASSWORDDatabase password
    DB_DATABASEDatabase name

    Attach Persistent Volumes

    Add persistent storage:

    Mount PathRecommended SizePurpose
    /var/www/html/image20+ GBProduct images
    /var/www/html/system/storage10 GBCache and logs
    /var/www/html/extension5 GBInstalled extensions

    Deploy Your Application

    Click Deploy to build and launch your OpenCart instance.

    Complete Installation

    Access your deployment and complete the installation wizard. Configure your store settings, add products, and set up payment gateways.

Additional Resources