OpenCart is a lightweight, straightforward open-source e-commerce platform — a good fit for smaller stores or those wanting simpler setup and lower resource requirements than Magento or even PrestaShop.
Prerequisites
- Ubuntu 22.04/24.04 VPS: 2 vCPU, 2-4 GB RAM
- Nginx or Apache, PHP 8.1+, MySQL/MariaDB
Step 1 — Install Required PHP Extensions
sudo apt install php8.2-gd php8.2-curl php8.2-mbstring php8.2-xml php8.2-zip php8.2-mysql -y
Step 2 — Create the Database
sudo mysql
CREATE DATABASE opencart;
CREATE USER 'opencart'@'localhost' IDENTIFIED BY 'CHANGE_ME_STRONG_PASSWORD';
GRANT ALL PRIVILEGES ON opencart.* TO 'opencart'@'localhost';
FLUSH PRIVILEGES;
Step 3 — Download OpenCart
cd /var/www
sudo wget https://github.com/opencart/opencart/releases/download/VERSION/opencart-VERSION.zip
sudo unzip opencart-VERSION.zip -d opencart-temp
Step 4 — Move the Upload Directory Contents
sudo mv opencart-temp/upload/* /var/www/opencart/
sudo chown -R www-data:www-data /var/www/opencart
Step 5 — Rename Configuration Sample Files
cd /var/www/opencart
sudo cp config-dist.php config.php
sudo cp admin/config-dist.php admin/config.php
sudo chmod 644 config.php admin/config.php
Step 6 — Configure Nginx
server {
listen 80;
server_name yourdomain.com;
root /var/www/opencart;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
}
Step 7 — Run the Web Installer
http://yourdomain.com
Follow the setup wizard, entering database credentials matching Step 2.
Step 8 — Remove the Install Directory
sudo rm -rf /var/www/opencart/install
Required both for OpenCart to function correctly and as an important security measure.
Step 9 — Secure the Admin Directory
Consider renaming the default admin directory and restricting access by IP where feasible, for an additional security layer beyond the login itself.
Step 10 — Add HTTPS
sudo certbot --nginx -d yourdomain.com
Step 11 — Configure Your Store
Add products, configure shipping/payment methods, and customize your store's theme from the admin panel.
Extending OpenCart
OpenCart has a marketplace of extensions for additional payment gateways, shipping integrations, and features — review extension quality and maintenance status before installing, as with any third-party plugin ecosystem.
Common Errors
"Warning: Could not modify configuration file" — verify file permissions on config.php and admin/config.php allow the web server to write during setup.
Continue Reading
- Choosing Between WooCommerce, Magento, PrestaShop, and OpenCart
- E-commerce Security Checklist: Protecting Customer Data on a VPS
- How to Set Up Automated Backups for an E-commerce Store
Browse more articles in E-commerce Platform Deployment.