OpenCart Installation and Setup
OpenCart installation is not just unpacking an archive. Properly configured server, correct PHP and database configuration, file system permissions, and initial CMS configuration are interconnected solutions that determine store stability and performance for years to come.
Server Requirements
OpenCart 4.x requires:
| Component | Minimum | Recommended |
|---|---|---|
| PHP | 8.0 | 8.2+ |
| MySQL | 5.7 | 8.0 |
| MariaDB | — | 10.6+ |
| Web Server | Apache / nginx | nginx |
| PHP Extensions | curl, zip, zlib, gd, mysqli, mbstring | + opcache, redis |
| PHP Memory | 128 MB | 256 MB+ |
Check extensions:
php -m | grep -E 'curl|zip|gd|mysqli|mbstring|redis|opcache'
PHP Configuration
File php.ini or directive in nginx.conf:
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_vars = 10000
date.timezone = Europe/Minsk
; Mandatory for performance
opcache.enable = 1
opcache.memory_consumption = 256
opcache.max_accelerated_files = 20000
opcache.revalidate_freq = 60
max_input_vars = 10000 is important for working with large forms in OpenCart (product option configuration can send many fields).
nginx Configuration
server {
listen 443 ssl http2;
server_name myshop.by www.myshop.by;
root /var/www/myshop/public_html;
index index.php;
# SSL (Let's Encrypt or commercial certificate)
ssl_certificate /etc/letsencrypt/live/myshop.by/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/myshop.by/privkey.pem;
# SEO URL
location / {
try_files $uri $uri/ @opencart;
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
# Restrict access to system files
location ~ ^/(system|admin/config\.php|config\.php) {
deny all;
}
# PHP processing
location ~ \.php$ {
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 300;
}
# Static assets caching
location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff2)$ {
expires 30d;
add_header Cache-Control "public, no-transform";
}
}
# HTTP → HTTPS redirect
server {
listen 80;
server_name myshop.by www.myshop.by;
return 301 https://myshop.by$request_uri;
}
OpenCart Installation
Step 1: Download and extract
cd /var/www/myshop
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
cp -r upload/* public_html/
cd public_html
Step 2: Copy configuration templates
cp config-dist.php config.php
cp admin/config-dist.php admin/config.php
Step 3: Set permissions
# Directories for writing
chmod 775 system/storage/cache/
chmod 775 system/storage/logs/
chmod 775 system/storage/download/
chmod 775 system/storage/upload/
chmod 775 image/
chmod 775 image/cache/
chmod 664 config.php admin/config.php
chown -R www-data:www-data /var/www/myshop/public_html/
Step 4: Create database
CREATE DATABASE opencart CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'opencart_user'@'localhost' IDENTIFIED BY 'strong_password_here';
GRANT ALL PRIVILEGES ON opencart.* TO 'opencart_user'@'localhost';
FLUSH PRIVILEGES;
Step 5: Web-based installation
Open https://myshop.by/install/ and follow 4 steps:
- License agreement
- Requirements check (all items should be green)
- Database and administrator settings
- Completion
After completion, delete the /install/ folder:
rm -rf public_html/install/
Move storage outside web root
By default, system/storage/ is inside web root — this is unsafe (direct access to logs and cache). Move it:
mv public_html/system/storage/ /var/www/myshop/storage/
In config.php:
define('DIR_STORAGE', '/var/www/myshop/storage/');
In admin/config.php — similarly. Restart PHP-FPM.
Initial setup via admin panel
System → Settings → General:
- Store Name, Address, Email, Phone
- Meta Title (homepage title)
System → Settings → Server:
- Use SEO URL's: Yes (mandatory)
- Output Compression Level: 5 (gzip)
- Error Display: No (on production)
- Error Log: Yes
System → Settings → Image:
- Image Width/Height for different contexts:
- Category image: 300×300
- Product image (catalog): 400×400
- Product image (card): 800×800
- Cart image: 100×100
Incorrect image sizes are a common cause of slow loading: OpenCart creates thumbnails on first access, large sizes = long generation.
Locale Configuration
System → Localization → Languages → Russian
→ Status: Enabled
→ Sort Order: 1
System → Localization → Currencies → Russian Ruble
→ Code: RUB
→ Symbol Left: (empty)
→ Symbol Right: ₽
→ Decimal Places: 2
→ Status: Enabled
→ Default: Yes
System → Localization → Currencies → Belarusian Ruble
→ Code: BYN
→ Symbol Right: Br
Update currency rates (automatically from ECB/Yahoo Finance or manually):
System → Localization → Currencies → Update Currency Rates
Connect SSL/HTTPS
After installing SSL certificate:
System → Settings → Server
→ Use SSL: Yes
→ HTTPS server: https://myshop.by/
If site is behind Cloudflare or proxy — additionally in index.php at the beginning of file:
// If proxy passes HTTPS
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
$_SERVER['HTTPS'] = 'on';
}
Security After Installation
- Rename
/admin/to unpredictable name (e.g./store-control-9x7k/) - Setup HTTP Basic Auth on admin folder as second factor
- Update
admin/config.phpwith new path - Add
location /store-control-9x7k { auth_basic ...; }to nginx - Install two-factor authentication extension to admin
Timeline
- Basic installation on prepared server: 2–4 hours
- nginx + PHP + SSL setup from scratch: 4–8 hours
- Initial store configuration (locale, settings, security): 2–3 hours
- Total: 1 working day.







