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 extensionsRUN 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 modulesRUN a2enmod rewrite
# Download OpenCartWORKDIR /var/www/htmlRUN 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 permissionsRUN 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:
| Variable | Description |
|---|---|
DB_HOSTNAME | Database host |
DB_USERNAME | Database user |
DB_PASSWORD | Database password |
DB_DATABASE | Database name |
Attach Persistent Volumes
Add persistent storage:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/var/www/html/image | 20+ GB | Product images |
/var/www/html/system/storage | 10 GB | Cache and logs |
/var/www/html/extension | 5 GB | Installed 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.