To install OpenCart on a VPS, build a supported Ubuntu web stack, create an empty database and a dedicated database user, unpack OpenCart into the site directory, copy its distribution configuration files, assign ownership to the web server, configure a virtual host, and finish the browser installer. Use PHP 8.1 or newer: the current official requirements specify 8.1+, while older upgrade documentation and some installer checks refer to earlier versions.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
What you need before you start
This procedure assumes a new Ubuntu VPS and an OpenCart release downloaded from its official release channel. The exact release number and download address are not established here, so select the current release before beginning and record the filename you downloaded. You need:
As an Amazon Associate I earn from qualifying purchases.
- Root or sudo access to the VPS.
- A domain name pointed at the VPS address, or a temporary hostname for testing.
- An Ubuntu installation. Tutorials commonly cover Ubuntu 18.04, 20.04 and 22.04; OpenCart’s official operating-system support matrix is not specified, so use a currently maintained Ubuntu LTS where possible.
- At least one free database name, one dedicated database user and a strong, unique password.
- The OpenCart ZIP archive and a way to upload it, such as SCP or an SSH session that downloads it.
Take a VPS snapshot before changing the web stack. Keep the root password or SSH key private, and use a non-root administrative account for routine work.
OpenCart requirements: PHP version, extensions and services
The current official requirements list PHP 8.1 or newer. An installation guide still performs a PHP 8.0-or-newer preflight check, and an older administration upgrade page says 7.4 or newer; that older figure should not be used for a new deployment. Community reports of installer failures on PHP 8.0.x and success on 8.1.x are anecdotal, but they reinforce the safer choice of PHP 8.1 or later.
#1 Best Overall
| Component | Requirement or recommendation | Notes |
|---|---|---|
| PHP | 8.1 or newer | Use the newest PHP version supported by the OpenCart release and your Ubuntu repositories. |
| PHP extensions | Curl, ZIP, Zlib, GD Library and mbstring | These are listed by the official requirements. Tutorials also install Intl, XML and MySQL support. |
| Database | MySQLi is the usual choice | The installation guide also accepts PDO and PostgreSQL, but the VPS procedure below uses MySQL or MariaDB. |
| Web server | Apache is the officially suggested option | Nginx can be used, but the available installation notes are less detailed and require PHP-FPM and equivalent rewrite rules. |
| Rewrite support | Apache’s rewrite module enabled |
Without it, clean URLs and some storefront routes can fail. |
Do not install an old PHP branch merely because an outdated page lists it. Confirm the active interpreter with php -v and confirm loaded modules with php -m.
Install the Ubuntu web stack
Log in over SSH, update package metadata and install Apache, the database server, PHP and the extensions used by OpenCart. On Ubuntu, the web server account is normally www-data.
sudo apt update
sudo apt upgrade -y
sudo apt install -y apache2 mysql-server php php-cli php-curl php-zip php-gd php-mbstring php-intl php-xml php-mysql unzip
The package names can vary by Ubuntu release. If your distribution supplies a versioned PHP package, install the matching version of each extension instead of mixing branches. Check the result:
php -v
php -m | grep -E 'curl|gd|mbstring|mysqli|PDO|xml|zip|zlib'
sudo systemctl status apache2
sudo systemctl status mysql
Enable the services at boot if they are not already enabled:
sudo systemctl enable --now apache2
sudo systemctl enable --now mysql
Zlib is commonly provided by the PHP build rather than a separately named package. If the OpenCart preflight reports it missing, inspect php -m and install the PHP package appropriate to your Ubuntu release rather than guessing a package name.
Rank #2
Create the OpenCart MySQL database and user
Use a separate database and login for this store. An empty database prevents an accidental collision with another application, and a dedicated account limits the impact of a compromised store.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsStart the database shell:
sudo mysql
Run SQL with your own database name, username and long random password. The values below are examples; do not deploy them unchanged.
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;
Store the credentials in a password manager. In the web installer, the database host is usually localhost when MySQL runs on the same VPS, the port is normally 3306, and the database driver should match the available MySQLi/PHP support. Do not give the store’s account global privileges such as GRANT ALL ON *.*.
Test the account before opening the installer:
mysql -u opencart_user -p -h localhost opencart_db
If this login fails, correct the username, password, host or grant now. A browser installer cannot repair a database account that cannot authenticate from the server.
Set PHP memory and timezone
One VPS installation guide recommends a 512M PHP memory limit and setting a timezone in php.ini. These values help avoid resource failures during installation and administration, but the correct timezone is the one used by your business and logs.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Rank #3
- No more Password Aggravation:This book will simplify your electronic life and free you from the constant frustration of trying to remember and reset your passwords. You can record longer and more complex passwords and never forget them again.
- Alphabetical Tabs (A-Z): We upgraded to one letter one tab(A-Z),others are two letters share 5 pages(AB-YZ). Our password journal has 6 pages per alphabetical tab. Makes your password easy to find and keeps organized.
- Plenty of Space for Information: Each tab has 6 pages with 4 entries per page, it can contain over 552 passwords. There're additional pages, PC info, email settings and 6 pages of notes. We have reserved a place to write a password hint instead of the password itself to ensure password security.
- 100GSM No-Bleed Paper: This password notebooks are made of very thick 100gsm paper, no bleed through. Size 5.3in x 7.7in, suitable size for carry-on. 180°lay flat so it’s easy to write in.
- Excellent Gift to All Ages:Easy to use, keeps passwords organized. With an elastic band, pen holder, bookmarker and inner pocket. A great present for friends and family.
- Find the PHP version that Apache uses with
php -v. The Apache configuration path includes that version, such as/etc/php/8.1/apache2/php.ini. - Open the file as root and set
memory_limit = 512M. - Set
date.timezoneto an applicable IANA timezone, such asUTCor your operating location. - Restart Apache so the web process loads the changes:
sudo systemctl restart apache2.
CLI PHP and Apache PHP can use different configuration files. If the browser preflight shows a value different from php -i on the shell, inspect the Apache-specific file rather than assuming the command-line setting is active.
Download and unpack OpenCart
Download the current OpenCart ZIP from the official release channel over HTTPS. Upload it to the VPS with SCP or download it directly, then unpack it outside the public directory first if you want to inspect the archive.
sudo mkdir -p /var/www/html/opencart
cd /tmp
unzip opencart-RELEASE.zip -d opencart-package
sudo cp -a opencart-package/upload/. /var/www/html/opencart/
Use the actual filename in place of opencart-RELEASE.zip. Some archives contain an upload directory and others may have a different top-level layout. The destination must contain OpenCart’s storefront files, including the configuration distribution file and the admin directory; avoid creating an unnecessary nested path such as /var/www/html/opencart/upload/upload.
Confirm the expected files:
sudo ls -la /var/www/html/opencart
sudo ls -la /var/www/html/opencart/admin
Prepare the two OpenCart configuration files
OpenCart ships example configuration files named config-dist.php. Copy one to config.php in the storefront root and another in the administration directory before starting the browser installer.
Recommended Free Tools
cd /var/www/html/opencart
sudo cp config-dist.php config.php
sudo cp admin/config-dist.php admin/config.php
If your release places these files in a different directory, preserve the same relationship: each directory containing config-dist.php needs its corresponding writable config.php. Do not delete the distribution files; they are useful when comparing a future upgrade’s configuration requirements.
Rank #4
Set ownership and safe filesystem permissions
The Apache process must be able to read the application and write the locations OpenCart uses during installation. On Ubuntu, assign the tree to www-data:
sudo chown -R www-data:www-data /var/www/html/opencart
sudo find /var/www/html/opencart -type d -exec chmod 755 {} ;
sudo find /var/www/html/opencart -type f -exec chmod 644 {} ;
The installer and extensions may need write access to specific storage, image, cache or configuration paths. If the preflight identifies a non-writable directory, grant access only to that path and record the change. Avoid making the entire site world-writable with chmod -R 777; it weakens the VPS without solving ownership mistakes.
Free tools Windows power users keep installed
One-click scans. No signup required.
After installation, review whether config.php and the admin configuration can be made less permissive while remaining readable by the web server. Keep backups outside the document root.
Configure an Apache virtual host
Create a site definition that points the domain at the OpenCart directory. Replace the example hostname with the domain whose DNS already points to this VPS.
sudo nano /etc/apache2/sites-available/opencart.conf
<VirtualHost *:80>
ServerName 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>
Enable the rewrite module and site, then reload Apache:
sudo a2enmod rewrite
sudo a2ensite opencart.conf
sudo apache2ctl configtest
sudo systemctl reload apache2
apache2ctl configtest must report a successful syntax check before you reload. Disable the default site if it captures the request instead:
sudo a2dissite 000-default.conf
sudo systemctl reload apache2
When DNS has propagated, visiting the domain should show OpenCart’s installer rather than Apache’s default page. If you use a temporary host, make sure the browser’s hostname matches ServerName or add a deliberate test entry in your local hosts file.
Complete the browser installer
Open http://your-domain.example. The installer checks PHP, extensions, file permissions and server settings before presenting the configuration screens.
- Read the license and continue only after the pre-install checks pass.
- Enter the database driver supported by your installation, the database host (normally
localhost), port, database name, database user and its password. - Provide a distinct administrator username, a long unique password and an email address you can access. Never reuse the VPS, SSH or database password.
- Confirm the storefront URL and administration path if the release asks for them. Ensure the URL uses the final domain, including the correct HTTP or HTTPS scheme once TLS is configured.
- Submit the form and wait for the success screen. A partially completed request can leave tables behind; if you restart, use the same empty database only after checking what the failed attempt created.
Do not leave the installer directory in a live site. After the success screen, remove it from the document root:
sudo rm -rf /var/www/html/opencart/install
Confirm that the storefront loads in a private browser window and that the administration URL accepts the administrator account. Keep the database credentials and the final admin path out of publicly shared screenshots and support tickets.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Enable HTTPS and finish the production setup
Before accepting customer accounts or payments, serve the store over HTTPS with a certificate issued for the domain. Configure the HTTP virtual host to redirect to HTTPS and verify that the OpenCart storefront, administration area, images and checkout do not contain mixed-content requests. The exact certificate procedure depends on your certificate authority and is separate from the OpenCart installer.
- Use strong, unique credentials for SSH, the database and OpenCart administration.
- Restrict SSH and database exposure with the VPS firewall; MySQL does not need to be publicly reachable when the store and database share one server.
- Keep Ubuntu packages, PHP, Apache, MySQL or MariaDB and OpenCart updated, testing upgrades on a snapshot or staging copy first.
- Schedule database and file backups, and periodically verify that a backup can actually be restored.
- Monitor Apache and PHP logs, disk space and memory. A full disk can look like a PHP or database failure.
Apache or Nginx for an OpenCart VPS?
| Choice | When it fits | What to plan for |
|---|---|---|
| Apache | Best match for the documented VPS procedure and official suggestion. | Enable mod_rewrite, allow the directory’s override rules and maintain the virtual host. |
| Nginx | Useful when you already operate an Nginx/PHP-FPM stack or need a centralized reverse proxy. | Configure PHP-FPM, equivalent front-controller and rewrite behavior, static-file handling and upload limits yourself. The available installation guidance is less extensive than Apache’s. |
Do not run both servers on the same public port without a deliberate proxy design. For a first manual deployment, Apache reduces the number of OpenCart-specific decisions.
Quick Recap
Common installation failures and precise fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| The preflight rejects PHP | PHP is older than the supported baseline or Apache is loading a different PHP version from the shell. | Install and select PHP 8.1 or newer, then restart Apache and verify the version in the browser-facing environment. |
| An extension is marked missing | A required module such as Curl, ZIP, GD, mbstring, XML, Intl or MySQL support is absent from the Apache PHP installation. | Install the matching extension package, confirm it appears in php -m, and restart Apache. |
| “Access denied” during database setup | The username, password, host or grant does not match the account created in MySQL. | Test the exact account from SSH, inspect its grant for the selected database, and enter the same host value in the installer. |
| Apache shows its default page | The OpenCart virtual host is disabled, DNS points elsewhere or the default site wins the request. | Check DNS, ServerName, enabled sites and apache2ctl configtest; disable the default site when appropriate. |
| Clean URLs return 404 errors | Apache rewrite support or directory overrides are disabled. | Enable rewrite, set AllowOverride All for the OpenCart directory and reload Apache. |
| Installer reports unwritable files | The files belong to your SSH user or have restrictive permissions. | Assign ownership to www-data and adjust only the directories OpenCart identifies; do not use world-writable permissions. |
| HTTP 500 or a blank page | A PHP fatal error, incompatible extension, syntax error or memory limit is likely. | Read the OpenCart and Apache error logs, run the Apache configuration test, verify the PHP version and extensions, and check the configured memory limit. |
| The installer warning remains after success | The install directory is still present. |
Delete /var/www/html/opencart/install and reload the site. |
Deployment checklist
- Ubuntu is updated and the VPS has a snapshot or recoverable backup.
- PHP 8.1 or newer is active for Apache.
- Curl, ZIP, Zlib, GD, mbstring, XML, Intl and MySQL support pass the preflight checks.
- MySQL or MariaDB contains an empty OpenCart database and a dedicated least-scope user.
config.phpexists in both the storefront root andadmindirectory.- The OpenCart tree is owned by
www-dataand only required paths are writable. - The Apache virtual host points to the correct document root, with rewrite enabled.
- The browser installer completes without warnings.
- The
installdirectory is removed immediately after installation. - HTTPS, unique passwords, package updates, firewall rules and tested backups are in place before launch.
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.




