Tutorials  /  Ubuntu

Install OpenCart on Ubuntu 20.04 with Nginx and SSL

Ccentron Redaktion · June 2025 ·6 min read ·Ubuntu, Tutorial

OpenCart is a well-known, open-source eCommerce platform developed to provide strong functionality, user-friendly handling, and centralized control of online shops through a single backend interface. With OpenCart, you can effortlessly create a comprehensive online store and adapt it using free add-ons to fit your business requirements.

This tutorial walks you through setting up OpenCart on an Ubuntu 20.04 server using the LEMP stack (Nginx, MySQL, PHP). Before beginning the installation, make sure your system fulfills the necessary prerequisites.

Install the Prerequisites

  • Deploy an Ubuntu 20.04 LEMP server
  • Access your server via SSH and sign in as the root user.
  • Update the system packages on your server.
  • Optionally, set up a domain name to resolve to your server’s IP address.
VM

Matching infrastructure at centron

Ubuntu servers without your own hardware: ccloud³ VMs with full root access from €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Set Up the OpenCart Database

First, log into the MySQL shell.

Console
$ mysql -u root

Create a fresh database to be used by OpenCart.

Code
mysql> create database opencart;

Establish a new MySQL user and assign a robust password to it.

Code
mysql> create user 'admin'@'localhost' IDENTIFIED BY 'YOUR_STRONG_PASSWORD';

Give the newly created user full access permissions to the database.

Code
mysql> GRANT ALL PRIVILEGES ON opencart.* TO 'admin'@'localhost';

Apply the permission changes and exit the MySQL interface.

Code
mysql> FLUSH PRIVILEGES;
mysql> EXIT

Download OpenCart

Download the latest stable OpenCart release from its official GitHub page. In this example, version 3.0.3.8 is used, though it's advised to verify and fetch the most recent version.

Console
$ wget https://github.com/opencart/opencart/releases/download/3.0.3.8/opencart-3.0.3.8.zip

Unzip the OpenCart archive to extract the contents.

Console
$ unzip opencart-3.0.3.8.zip -d opencart

Transfer the extracted OpenCart files to your web server’s document root. On Nginx, this is typically located at /usr/share/nginx/html.

Console
$ sudo mv opencart/upload/* /usr/share/nginx/html

Assign ownership of the web root directory to the www-data user and group to ensure Nginx can access the files.

Console
$ sudo chown -R www-data:www-data /usr/share/nginx/html

Prepare the Installation Files

To begin the OpenCart setup, rename the sample configuration files to their appropriate filenames for a production environment.

Console
$ cd /usr/share/nginx/html
$ sudo mv config-dist.php config.php
$ sudo mv admin/config-dist.php admin/config.php

Configure the Firewall

Enable incoming web traffic by opening HTTP and HTTPS ports on your firewall.

Console
$ sudo ufw allow 80 
$ sudo ufw allow 8080
$ sudo ufw allow http
$ sudo ufw allow https

Install a Free SSL/TLS Certificate

As both OpenCart and modern web browsers rely on HTTPS for secure connections, setting up a free SSL/TLS certificate is crucial to prevent browser warnings. Begin by installing Certbot and the necessary Nginx plugin.

Console
$ sudo apt install certbot python3-certbot-nginx

Use Certbot to request a new SSL certificate for your domain name.

Console
$ certbot –nginx -d example.com www.example.com

During the process, you'll be prompted to enter your email, accept the terms of service, and configure HTTPS preferences. Once complete, a functional SSL certificate will be installed automatically.

IMPORTANT NOTES:

– Congratulations! Your certificate and chain have been saved at:

/etc/letsencrypt/live/example.com/fullchain.pem

Your key file has been saved at:

/etc/letsencrypt/live/example.com/privkey.pem

Install OpenCart

Open your browser and navigate to your server's public IP address or the configured domain name to initiate the OpenCart setup.

http://example.com

On the welcome screen, select “Continue” to agree to the terms and conditions.

OpenCart will automatically verify if the server fulfills all necessary requirements. When all checks pass, click “Continue” to move forward.

Provide the database name, user, and password that you set up in the initial database configuration step of this guide.

OpenCart Database Settings

Click the continue button to finalize the installation. You will then be redirected to the OpenCart admin dashboard, where you can proceed with additional configurations and store customization.

Securing OpenCart

When using OpenCart on a live production environment, it is essential to enhance security by executing the following steps.

First, remove the installation directory to prevent unauthorized access to setup routines.

Console
$ sudo rm -r /usr/share/nginx/html/install

Next, modify file permissions of critical OpenCart files to 644 to reduce the risk of unauthorized modifications.

Console
$ sudo chmod  644 /usr/share/nginx/html/config.php
$ sudo chmod  644 /usr/share/nginx/html/index.php
$ sudo chmod  644 /usr/share/nginx/html/admin/config.php
$ sudo chmod  644 /usr/share/nginx/html/admin/index.php
$ sudo chmod  644 /usr/share/nginx/html/system/startup.php

To protect the administrator area, rename the default admin directory to a more discreet name of your choice, such as privatemin.

Console
$ sudo mv /usr/share/nginx/html/admin privatemin

After renaming the directory, the login path for the OpenCart administration panel will change accordingly. In this example, it becomes:

https://example.com/privatemin

You may substitute privatemin with any custom keyword you prefer to further obscure the login route.

Conclusion

Well done! You have successfully completed the installation of OpenCart on your Ubuntu 20.04 server. You can now begin configuring and launching your new online store by accessing your server’s IP address or the linked domain name in a web browser.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Ubuntu
Teilen
Noch offene Fragen?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

War dieses Tutorial hilfreich?

Your answer is stored anonymously and helps us improve our tutorials.

Kommentare

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren