How can we help?
Categories
< All Topics
Print

Install OpenCart on a ServerStadium Dedicated Server

Introduction

Launch a fast OpenCart store on a ServerStadium dedicated server (or ServerStadium VM) running Ubuntu 24.04. This quickstart walks beginners through installing OpenCart 4, enabling SEO-friendly URLs, adding free HTTPS via Let’s Encrypt, and getting sample data/themes in place—so you can start selling today on reliable ServerStadium hardware.

Prerequisites

  • A ServerStadium dedicated server or VM with Ubuntu 24.04 and a domain pointed to your server’s IP.
  • SSH access with a sudo-capable user.
  • An email address for Let’s Encrypt and an SMTP provider (for order emails).

Step 1 — Install LAMP and PHP Extensions

OpenCart 4 requires PHP 8.1+ with common extensions. Install Apache, MariaDB/MySQL, and PHP on Ubuntu 24.04:

sudo apt update && sudo apt -y upgrade
sudo apt -y install apache2 mysql-server \
  php libapache2-mod-php php-mysql php-curl php-zip php-xml php-gd php-mbstring php-intl \
  unzip curl
sudo a2enmod rewrite
sudo systemctl enable --now apache2 mysql

Step 2 — Create Database and User

sudo mysql_secure_installation

sudo mysql -e "CREATE DATABASE ocdb DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;"
sudo mysql -e "CREATE USER 'ocuser'@'localhost' IDENTIFIED BY 'ChangeThisStrongPassword!';"
sudo mysql -e "GRANT ALL PRIVILEGES ON ocdb.* TO 'ocuser'@'localhost'; FLUSH PRIVILEGES;"

Step 3 — Download OpenCart 4.1.0.3

Grab the latest OpenCart 4 release and unpack it.

cd /tmp
wget -O opencart.zip "https://sourceforge.net/projects/opencart.mirror/files/4.1.0.3/opencart-4.1.0.3.zip/download"
unzip opencart.zip

Step 4 — Deploy Files and Set Permissions

sudo mkdir -p /var/www/opencart
# OpenCart zip contains an "upload" directory. Copy its contents to your web root.
sudo rsync -a upload/ /var/www/opencart/

# Rename config templates as required by the installer
sudo cp /var/www/opencart/config-dist.php /var/www/opencart/config.php
sudo cp /var/www/opencart/admin/config-dist.php /var/www/opencart/admin/config.php

# Prepare .htaccess for SEO URLs
sudo mv /var/www/opencart/htaccess.txt /var/www/opencart/.htaccess

# Ownership/permissions
sudo chown -R www-data:www-data /var/www/opencart
sudo find /var/www/opencart -type d -exec chmod 755 {} \;
sudo find /var/www/opencart -type f -exec chmod 644 {} \;

# Allow installer to write config files during setup (we'll lock down later)
sudo chmod 664 /var/www/opencart/config.php /var/www/opencart/admin/config.php

Step 5 — Configure Apache Virtual Host

Replace example.com with your domain.

sudo tee /etc/apache2/sites-available/opencart.conf >/dev/null <<'EOF'
<VirtualHost *:80>
  ServerName example.com
  ServerAlias www.example.com
  DocumentRoot /var/www/opencart

  <Directory /var/www/opencart>
    AllowOverride All
    Require all granted
  </Directory>

  ErrorLog ${APACHE_LOG_DIR}/oc_error.log
  CustomLog ${APACHE_LOG_DIR}/oc_access.log combined
</VirtualHost>
EOF

sudo a2ensite opencart.conf
sudo apache2ctl configtest && sudo systemctl reload apache2

Step 6 — Enable HTTPS with Let’s Encrypt

sudo apt -y install certbot python3-certbot-apache
sudo certbot --apache -d example.com -d www.example.com --redirect -m you@example.com --agree-tos -n

Step 7 — Run the Web Installer

  • Open https://example.com and follow the installer.
  • Database: ocdb, User: ocuser, Password: ChangeThisStrongPassword!, Host: localhost.
  • Admin path: keep the suggested unique URL for security.

After installation, tighten configs and (optionally) move storage outside the web root:

# Lock down configs
sudo chmod 644 /var/www/opencart/config.php /var/www/opencart/admin/config.php

# (Optional) Move storage folder outside the web root for security
sudo mkdir -p /var/www/oc-storage
sudo rsync -a /var/www/opencart/system/storage/ /var/www/oc-storage/
# Update both config files so DIR_STORAGE points to /var/www/oc-storage/
sudo sed -i "s#'DIR_STORAGE'.*#'DIR_STORAGE', '/var/www/oc-storage/' );#g" /var/www/opencart/config.php
sudo sed -i "s#'DIR_STORAGE'.*#'DIR_STORAGE', '/var/www/oc-storage/' );#g" /var/www/opencart/admin/config.php

Step 8 — Turn On SEO-Friendly URLs

  • In Admin: System → Settings → Your Store → Server → enable Use SEO URLs.
  • You already renamed htaccess.txt to .htaccess and enabled mod_rewrite in earlier steps.

Step 9 — Sample Data & Theme Basics

  • Sample data: OpenCart ships with demo products/categories on fresh installs. Replace them under Catalog → Products/Categories as you build your store.
  • Themes: Go to Extensions → Extensions, choose “Themes”, edit Your Store, select a theme (or install one via Extensions → Installer), then enable and save.

Step 10 — Email & Payments

  • Order email: In System → Settings → Your Store → Mail, choose SMTP and enter your provider’s host, port, encryption, username, and password; send a test email.
  • Gateways: In Extensions → Extensions (choose “Payments”), install Stripe/PayPal and connect your merchant account.

Optional: Quick Backup Script

sudo mkdir -p /opt/oc-backups
sudo tee /opt/oc-backups/backup.sh >/dev/null <<'EOF'
#!/usr/bin/env bash
set -e
TS=$(date +%F-%H%M)
SITE_ROOT="/var/www/opencart"
DB_NAME="ocdb"
DB_USER="ocuser"
DB_PASS="ChangeThisStrongPassword!"

mkdir -p /opt/oc-backups/${TS}
mysqldump -u ${DB_USER} -p${DB_PASS} ${DB_NAME} | gzip > /opt/oc-backups/${TS}/db.sql.gz
tar -czf /opt/oc-backups/${TS}/site-files.tgz -C "${SITE_ROOT}" .
find /opt/oc-backups -maxdepth 1 -type d -mtime +14 -exec rm -rf {} \; 2>/dev/null || true
EOF

sudo chmod +x /opt/oc-backups/backup.sh
echo "30 2 * * * root /opt/oc-backups/backup.sh" | sudo tee /etc/cron.d/oc-backup >/dev/null

Troubleshooting

  • Installer fails requirements: Confirm PHP extensions (curl, zip, zlib, gd, mbstring, intl) are installed.
  • SEO URLs not working: Ensure mod_rewrite is enabled, your vHost allows AllowOverride All, and .htaccess exists in the web root.
  • Permission errors: Temporarily set config.php files to 664 for installation, then restore to 644.
  • SSL issues: Verify DNS points to your server before running Certbot; re-run with --apache if needed.

Want a faster start? Choose an instant, low-cost ServerStadium dedicated server and be online today.

Conclusion

Your OpenCart store is now live with HTTPS, SEO URLs, and a theme foundation—ready for products, payments, and growth on ServerStadium. For more help or information about ServerStadium services, visit our knowledge base or the ServerStadium website.

Table of Contents