DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
VGSources
Blog

How to Install OpenCart on a VPS (Ubuntu Guide)

A complete Ubuntu VPS walkthrough for OpenCart: install the supported PHP stack, create a MySQL database, configure Apache, run the browser installer and harden the finished store.
Length9 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To install OpenCart on a VPS, build an Ubuntu web stack, create an empty MySQL or MariaDB database, place the OpenCart files in your document root, prepare the two configuration files, point a virtual host at the site, and finish the browser installer. Use PHP 8.1 or newer: the current OpenCart requirements specify 8.1+, while older installer and upgrade notes are inconsistent.

This guide uses Apache because it is the officially suggested server and is the setup covered by most OpenCart tutorials. Nginx can work, but its rewrite configuration is more manual.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What you need before starting

You need a fresh Ubuntu VPS with sudo access, a domain name pointed at the server, and enough access to install system packages and edit Apache and PHP configuration. The exact Ubuntu release is not specified by OpenCart’s current requirements; tutorials commonly use Ubuntu 18.04, 20.04 and 22.04. Whichever supported Ubuntu image your VPS provider offers, update it fully before installing the application.

OpenCart requirements

Component Requirement or recommendation
PHP PHP 8.1 or newer. This follows the current official requirements; older PHP notes are stale or have reported compatibility problems.
PHP extensions Curl, ZIP, Zlib, GD Library and mbstring. Installing php-intl, php-xml and php-mysql also covers common tutorial and application needs.
Database MySQLi is the usual choice. OpenCart’s installation documentation also accepts PDO and PostgreSQL, while this procedure uses MySQL or MariaDB.
Web server Apache is officially suggested. Nginx is possible with a suitable rewrite configuration.
Apache feature The rewrite module must be enabled for clean URLs and rules supplied with the store.

Do not rely on an old control-panel checklist that says PHP 7.4 or 8.0 is sufficient. The most recent requirements call for PHP 8.1+, and a community report describes the installer failing on some PHP 8.0.x systems while working on 8.1.x.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

1. Update Ubuntu and install the web stack

Log in over SSH, update package metadata, apply security updates, and install Apache, a database server, PHP and the extensions. The command below uses Ubuntu package names; the PHP package manager selects the current version available for your Ubuntu release.

sudo apt update
sudo apt full-upgrade -y
sudo apt install -y apache2 mysql-server php libapache2-mod-php php-cli php-mysql php-curl php-zip php-gd php-mbstring php-intl php-xml unzip

The php-mysql package provides the MySQLi driver used in the installer. Zlib is normally supplied by the PHP build and is checked by the installer; if the pre-install check reports it missing, install the Zlib package available for your specific Ubuntu/PHP repository rather than guessing a package name.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Start the services and make them persistent across reboots:

sudo systemctl enable --now apache2
sudo systemctl enable --now mysql

Confirm the PHP version that Apache will use after installation:

php -v
php -m

Check that the module list includes curl, gd, mbstring, mysqli, pdo, xml and zip. The browser pre-install check remains authoritative because command-line PHP and Apache can load different configuration files.

2. Create the OpenCart database and user

OpenCart should have its own empty database and a dedicated account. Do not reuse a hosting control-panel superuser or the MySQL root account. The database name, username and password you create here are entered verbatim in the web installer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Open a MySQL administrative shell:

sudo mysql

Run SQL with your own database name, username and long random password. The values below are examples only:

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
CREATE DATABASE opencart_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'opencart_user'@'localhost' IDENTIFIED BY 'replace-with-a-long-random-password';
GRANT ALL PRIVILEGES ON opencart_db.* TO 'opencart_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Keep a private record of the four installer values: database host (localhost for this local database), database name, username and password. If your database server is on another machine, use that server’s hostname and restrict the account’s allowed host instead of using localhost.

3. Tune PHP for the store

One OpenCart deployment tutorial recommends a 512M PHP memory limit. A larger limit gives the catalog, image processing and extensions room to run, but it does not replace fixing a script that leaks memory. Set the timezone explicitly so scheduled tasks and order timestamps are consistent.

Find the PHP version reported by php -v, then edit the Apache SAPI configuration at /etc/php/<version>/apache2/php.ini. For example, a PHP 8.1 installation uses /etc/php/8.1/apache2/php.ini:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo nano /etc/php/<version>/apache2/php.ini

Set or update these directives:

memory_limit = 512M
date.timezone = UTC

Replace UTC with the IANA timezone that matches your business location when appropriate. Restart Apache and verify the active values:

sudo systemctl restart apache2
php -i | grep -E 'memory_limit|date.timezone'

The command-line output is a useful check, but the installer check in the browser is the final confirmation for the web process.

4. Download and place the OpenCart files

Obtain the release ZIP from OpenCart’s official release channel. The current release number and download address are not fixed here, so select the release you intend to maintain and verify that its PHP requirements match this server.

Create a directory for the site and extract the archive. This example uses /var/www/html/opencart:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
sudo mkdir -p /var/www/html/opencart
sudo unzip /path/to/opencart-release.zip -d /var/www/html/opencart

Inspect the result before configuring Apache:

sudo find /var/www/html/opencart -maxdepth 2 -type f -name 'index.php' -o -name 'config-dist.php'
sudo ls -la /var/www/html/opencart

Some release archives place the application under an additional directory such as upload. Apache’s document root must be the directory that contains the storefront index.php, config-dist.php and the admin directory. If extraction created an extra wrapper directory, move or copy the contents so those files are directly under the directory you will serve.

Prepare both configuration files

OpenCart ships templates named config-dist.php. Copy the template to config.php in the storefront root and do the same inside the admin directory:

cd /var/www/html/opencart
sudo cp config-dist.php config.php
sudo cp admin/config-dist.php admin/config.php

If your extracted release uses a different document-root directory, run the commands there. The installer writes the connection and path settings into these files; creating them first avoids a missing-file error during setup.

5. Set ownership and permissions

On Ubuntu, Apache normally runs as www-data. Give that account ownership of the OpenCart directory so the installer can write its configuration and the application can manage its required runtime files:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo chown -R www-data:www-data /var/www/html/opencart

Keep the rest of the VPS under normal root or administrator ownership. Avoid making the entire web root world-writable with broad chmod 777 permissions; that hides ownership mistakes and creates an unnecessary security risk. If a later extension needs a writable cache or image directory, grant write access only to that directory and keep the scope documented.

6. Configure an Apache virtual host

Create a site definition whose DocumentRoot is the directory containing OpenCart’s index.php. Replace shop.example.com with the domain you have pointed to the VPS.

sudo nano /etc/apache2/sites-available/opencart.conf

Use this basic virtual host:

<VirtualHost *:80>
    ServerName shop.example.com
    ServerAlias www.shop.example.com
    DocumentRoot /var/www/html/opencart

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

    ErrorLog ${APACHE_LOG_DIR}/opencart-error.log
    CustomLog ${APACHE_LOG_DIR}/opencart-access.log combined
</VirtualHost>

AllowOverride All lets OpenCart’s rewrite rules in .htaccess work. Enable the site and rewrite module, test the configuration, then reload Apache:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
sudo a2enmod rewrite
sudo a2ensite opencart.conf
sudo apachectl configtest
sudo systemctl reload apache2

The configuration test should report Syntax OK. If Apache still serves its default page, disable the default site and reload:

sudo a2dissite 000-default.conf
sudo systemctl reload apache2

Visit the domain in a browser. A DNS error means the domain is not pointing at the VPS yet; an Apache error means to check the virtual-host file and the logs named in the configuration.

7. Complete the browser installer

Open the domain over HTTP for the first configuration pass, or use HTTPS if a certificate is already installed. The installer normally performs a license screen followed by a server pre-install check.

  1. Read and accept the license terms.
  2. Review the pre-install check. Resolve every PHP version, extension, file-permission or rewrite warning before continuing.
  3. Choose the MySQLi database driver unless your deployment deliberately uses another supported driver.
  4. Enter the database host, database name, database user and password created earlier. Use the normal MySQL port if the installer asks for one.
  5. Set a unique administrator username and a long, unique password. Do not use admin, the database password, or a password reused elsewhere.
  6. Confirm the storefront URL and administrative path if the installer presents them.
  7. Submit the form and wait for OpenCart to create its tables and write the two configuration files.

If the installer returns to the same screen, read its specific warning rather than repeatedly submitting the form. A database authentication error usually means one of the four connection values is wrong; a permissions warning points to ownership or the path served by Apache.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

8. Remove the installer and enable HTTPS

After the installer reports success, remove the installation directory from the served tree. Leaving it available can allow someone to rerun setup or expose diagnostic information.

sudo rm -rf /var/www/html/opencart/install

Confirm that the directory is gone and test both the storefront and /admin login. Then configure HTTPS with the certificate service supplied by your VPS host or your preferred certificate authority, and redirect HTTP traffic to HTTPS. HTTPS protects administrator credentials and customer sessions; it is a launch requirement, not an optional cosmetic setting.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Apache or Nginx for an OpenCart VPS?

Choice What the evidence supports Operational implication
Apache Officially suggested and used by most installation tutorials. Enable mod_rewrite and allow the OpenCart directory to use its rewrite file.
Nginx Possible alternative, with fewer official setup notes in the available guidance. Translate OpenCart’s rewrite behavior into the Nginx server block yourself; Nginx does not process Apache .htaccess files.

Choose Apache when you want the least deviation from the documented path. Choose Nginx only if you already operate it confidently and are prepared to maintain the equivalent rewrite and PHP-FPM configuration.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Troubleshooting common installation failures

The pre-install check rejects PHP

Verify the version used by Apache, not only the shell’s default:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
php -v
sudo apachectl -M | grep php

Move to PHP 8.1 or newer, ensure Apache is loading that version, restart Apache, and reload the installer. PHP 7.4 and many 8.0 installations are not a dependable target for a current OpenCart deployment.

An extension is reported missing

Compare the browser check with php -m. Install the missing Ubuntu package, restart Apache, and run the check again. The commonly required set is curl, ZIP, Zlib, GD, mbstring, plus intl, xml and MySQL support.

“Access denied” or “Unknown database” appears

Log in with the same account outside OpenCart to isolate the problem:

mysql -u opencart_user -p -h localhost opencart_db

If this fails, correct the database name, username, password, host or grant. If it succeeds, copy those exact values into the installer; do not add quotation marks or whitespace.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apache shows a 403, 404 or the default page

  • Check that DocumentRoot points to the directory containing index.php, not the parent directory created by ZIP extraction.
  • Confirm the virtual host is enabled and run sudo apachectl configtest.
  • For clean-URL failures, verify sudo a2enmod rewrite and AllowOverride All.
  • Check ownership with sudo ls -ld /var/www/html/opencart and review the OpenCart Apache error log.

A blank page or HTTP 500 occurs after installation

Inspect the Apache error log named in the virtual host, confirm that the PHP extensions are loaded for Apache, and check that memory_limit is not lower than the value required by your catalog and extensions. Correct the underlying error, restart Apache, and retest rather than suppressing errors or making the entire directory writable.

The installer works but the site fails after deleting install

Verify that both config.php files exist in the storefront and admin directories and that they remain readable by www-data. If the application was extracted into a different directory than the virtual host serves, correct the document root and rerun only the necessary configuration steps.

Pre-launch security checklist

  • Run Ubuntu and database security updates before opening the store to customers.
  • Use a dedicated database account with a long random password.
  • Use a unique OpenCart administrator username and password.
  • Remove the install directory immediately after a successful setup.
  • Serve the storefront and administrator over HTTPS.
  • Keep PHP, OpenCart, extensions and the operating system updated, testing updates in a backup or staging copy when possible.
  • Limit SSH and database exposure with your VPS firewall and provider controls.

Final verification

Before adding products, place a test order or at least exercise the storefront, administrator login, image upload and checkout-related pages. Confirm that URLs remain correct after enabling HTTPS, that Apache’s rewrite rules are active, and that the database user can connect without root privileges. Once those checks pass, the VPS has the essential OpenCart foundation: a supported PHP runtime, the required extensions, a dedicated database, correctly owned files, a working virtual host and the installer removed.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.