This guide installs OpenCart 4.0 on a self-hosted Linux server.
Current Version: 4.0.x (released 2023-2024)
⚠️ Note: No official OpenCart Docker image exists. Use manual installation or build custom Docker images.
| Component | Requirement |
|---|---|
| PHP | 8.0+ (8.1+ recommended) |
| Database | MySQL 5.7+ or MariaDB 10.2+ |
| Web Server | Apache 2.4+ or Nginx 1.x |
| PHP Extensions | curl, dom, fileinfo, gd, intl, json, mbstring, openssl, pdo, pdo_mysql, zip, zlib, xml, mysqli |
| Memory | 512MB RAM minimum (1GB+ recommended) |
# Required PHP extensions for OpenCart 4
curl dom fileinfo gd intl json mbstring openssl pdo pdo_mysql zip zlib xml mysqli
Ubuntu/Debian:
apt update
apt install apache2 mariadb-server git unzip curl
# Install PHP 8.1 and required extensions
apt install php8.1 libapache2-mod-php8.1 php8.1-mysql php8.1-curl php8.1-gd \
php8.1-intl php8.1-mbstring php8.1-xml php8.1-zip php8.1-opcache php-composer2
RHEL/Rocky Linux:
dnf install httpd mariadb-server git unzip curl
# Install PHP 8.1 and required extensions (requires EPEL/Remi repositories)
dnf install php php-mysqlnd php-curl php-gd php-intl php-mbstring php-xml \
php-zip php-opcache php-composer2
Create a database and user for OpenCart:
mysql -u root -p -e "CREATE DATABASE opencart CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
mysql -u root -p -e "CREATE USER 'opencart'@'localhost' IDENTIFIED BY 'strong-password-here';"
mysql -u root -p -e "GRANT ALL PRIVILEGES ON opencart.* TO 'opencart'@'localhost';"
mysql -u root -p -e "FLUSH PRIVILEGES;"
Option A: Composer (Recommended)
cd /var/www/html
composer create-project opencart/opencart opencart
Option B: Download Archive
cd /var/www/html
wget https://github.com/opencart/opencart/releases/download/4.0.2.3/opencart-4.0.2.3.zip
unzip opencart-4.0.2.3.zip
rm opencart-4.0.2.3.zip
chown -R www-data:www-data /var/www/html/opencart
find /var/www/html/opencart -type d -exec chmod 755 {} \;
find /var/www/html/opencart -type f -exec chmod 644 {} \;
chmod -R 755 /var/www/html/opencart/image
chmod -R 755 /var/www/html/opencart/system/storage
cd /var/www/html/opencart
cp config-dist.php config.php
cp admin/config-dist.php admin/config.php
Open http://YOUR-SERVER/opencart in your browser and follow the installation wizard.
Important: After installation, delete the install directory:
rm -rf /var/www/html/opencart/install
OpenCart requires cron jobs for scheduled tasks:
crontab -e -u www-data
Add:
0 * * * * cd /var/www/html/opencart && /usr/bin/php cli/cron.php
Edit config.php and set error reporting to off:
ini_set('display_errors', 0);
error_reporting(0);
For production, always use HTTPS. Configure via Apache/Nginx or place behind a reverse proxy with Let’s Encrypt.
In OpenCart admin, go to System → Settings → Server and enable SSL.
Consider installing these popular OpenCart extensions:
Prefer automation? See OpenCart Ansible Setup for an example playbook.
Prefer containers? See OpenCart Docker Setup.
Any questions?
Feel free to contact us. Find all contact information on our contact page.