Jul 6, 2023 7 min read

How to Install Opencart on Ubuntu 22.04

Install Opencart on Ubuntu 22.04 with our step-by-step tutorial. It empowers businesses to create and manage their online stores.

Install Opencart on Ubuntu 22.04
Table of Contents

Choose a different version or distribution


Before we begin talking about how to install OpenCart on Ubuntu 22.04, let's briefly understand – What is OpenCart?

OpenCart is an e-commerce platform that empowers businesses to create and manage their online stores. With its user-friendly interface and extensive features, Opencart allows entrepreneurs to sell products and services efficiently.

This open-source solution offers customizable themes, multiple payment gateways, and a wide range of extensions to enhance functionality. Opencart enables seamless inventory management, order tracking, and customer engagement. It is an ideal choice for businesses seeking a flexible and scalable e-commerce solution.

In this tutorial, you will install OpenCart on Ubuntu 22.04. We will also address a few FAQs on how to install OpenCart on Ubuntu 22.04.

Advantages of OpenCart

  1. User-Friendly Interface: OpenCart offers a straightforward and intuitive interface, making it easy for businesses to set up and manage their online stores.
  2. Customizability: With a wide range of customizable themes and extensions, OpenCart allows businesses to create unique and personalized e-commerce websites.
  3. Multiple Payment Gateways: OpenCart supports various payment gateways, providing customers with convenient and secure payment options.
  4. Inventory Management: OpenCart simplifies inventory management by allowing businesses to easily track and update product availability.
  5. Scalability: OpenCart is a scalable platform, capable of handling growing businesses and accommodating increasing product catalogs without compromising performance.

Step 1: Update Operating System

Use the command below to upgrade your Ubuntu 22.04 operating system to the most recent version:

sudo apt update && sudo apt upgrade -y

Step 2: Install Apache webserver

A cross-platform web server that is free and open-source is called Apache HTTP Server. By running the following line, you can install it using the apt package manager.

sudo apt install apache2

By executing the following commands, you can start the Apache service and set it up to begin immediately upon startup:

sudo systemctl start apache2
sudo systemctl enable apache2

Use the systemctl status command to check the Apache service's status:

sudo systemctl status apache2


● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 2975 (apache2)
      Tasks: 55 (limit: 2200)
     Memory: 4.8M
        CPU: 137ms
     CGroup: /system.slice/apache2.service
             ├─2975 /usr/sbin/apache2 -k start
             ├─2977 /usr/sbin/apache2 -k start
             └─2978 /usr/sbin/apache2 -k start

Step 3: Install PHP

Run the following command to install PHP and other PHP modules to enable OpenCart:

sudo apt-get install php php-cli libapache2-mod-php php-common php-mbstring php-gd php-intl php-xml php-mysql php-zip php-curl php-xmlrpc

Check to see if PHP is set up.

php -v
PHP 8.1.2 (cli) (built: Jun 13 2022 13:52:54) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies

Step 4: Install MariaDB and create a database

The flexible, dependable, and user-friendly database engine MariaDB is free and open source. Run the following command to install MariaDB:

sudo apt install mariadb-server mariadb-client

Use the systemctl status command to check the MariaDB service's status:

sudo systemctl status mariadb


● mariadb.service - MariaDB 10.6.7 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running)
       Docs: man:mariadbd(8)
    Process: 26067 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 26069 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 26072 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && >
    Process: 26149 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 26151 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 26109 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 7 (limit: 2200)
     Memory: 61.3M
        CPU: 2.585s
     CGroup: /system.slice/mariadb.service
             └─26109 /usr/sbin/mariadbd

MariaDB is not hardened by default. With the mysql_secure_installation script, you can secure MariaDB.

sudo mysql_secure_installation

Configure it as follows:

- Set root password? [Y/n] Y
- Remove anonymous users? [Y/n] Y
- Disallow root login remotely? [Y/n] Y
- Remove test database and access to it? [Y/n] Y
- Reload privilege tables now? [Y/n] Y

To access the MariaDB shell, execute the command below.

sudo mysql -u root -p

You must build a database for the OpenCart installation once you are signed in to your database server:

MariaDB [(none)]> CREATE DATABASE opencart;
MariaDB [(none)]> CREATE USER 'opencart'@'localhost' IDENTIFIED BY 'Your-Strong-Password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON opencart . * TO 'opencart'@'localhost';
MariaDB [(none)]> exit;

Step 5: Download OpenCart

Using the command line, you can get the most recent version of OpenCart from the Git repository:

sudo wget https://github.com/opencart/opencart/releases/download/

Then, extract the file to the /var/www/html/opencart/ folder using the command:

sudo apt -y install unzip 
sudo unzip opencart- -d /var/www/html/opencart/

Copy configuration files for OpenCart:

sudo cp /var/www/html/opencart/upload/{config-dist.php,config.php}

sudo cp /var/www/html/opencart/upload/admin/{config-dist.php,config.php}

Grant the Apache webserver user access to the files by enabling this permission:

sudo chown -R www-data:www-data /var/www/html/opencart/

Step 6: Create Virtualhost for Opencart

Then, make an OpenCart virtual host configuration file:

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

Copy and paste the text as follows:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/opencart/upload/
    ServerName your-domain.com
    ServerAlias www.your-domain.com

    <Directory /var/www/html/opencart/upload/>
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all

    ErrorLog /var/log/apache2/your-domain.com-error_log
    CustomLog /var/log/apache2/your-domain.com-access_log common

Don't forget to substitute your server's domain name for your-domain.com.

Save the configuration file, then close it.

Run the following command to enable this site and disable default conf:

sudo a2ensite opencart.conf
sudo a2dissite 000-default

Restart the Apache web server to apply the changes:

sudo systemctl restart apache2

Step 7: Access OpenCart Web Interface

Visit http://your-domain.com/ in your browser to get to the OpenCart Web Interface.

The licence agreement is shown on the first page. Click Continue after scrolling down.

Before pressing the Continue button, make sure that all necessary PHP extensions are installed.

You must fill the database details on the following page. Click Continue after entering the information you defined in the MariaDB database.

Following the installation, you should see the following page:

You should then see your shop page if you click the Go to your Online Shop:

Alternatively, if you click the Login to your Administration option, you should be taken to the login page:

Click the Login button after entering your admin login information. You should be able to see your administration panel:

Open your terminal now, and use the following command to remove the installation directory:

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

FAQs to Install OpenCart on Ubuntu 22.04

What are the system requirements to install OpenCart on Ubuntu 22.04?

OpenCart requires PHP, MySQL, and a web server like Apache or Nginx. Make sure you have PHP 7.2 or higher and MySQL 5.7 or higher installed.

What is the process to download and extract OpenCart on Ubuntu 22.04?

Visit the OpenCart website, download the latest version, and extract the downloaded file using the unzip command. Move the extracted files to the desired directory.

How do I create a MySQL database for OpenCart on Ubuntu 22.04?

Access MySQL through the terminal: mysql -u root -p. Enter your MySQL root password and run: CREATE DATABASE opencartdb; CREATE USER 'opencartuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON opencartdb.* TO 'opencartuser'@'localhost'; FLUSH PRIVILEGES; EXIT;

What configuration changes are required for OpenCart on Ubuntu 22.04?

Edit the Apache configuration file by running: sudo nano /etc/apache2/sites-available/000-default.conf. Set the DocumentRoot to the directory where OpenCart files are located. Save the changes and restart Apache.

How can I access the OpenCart installation wizard on Ubuntu 22.04?

Open a web browser and enter the URL: http://your_domain_name/install. Follow the instructions to complete the installation process.

What are the recommended file and folder permissions for OpenCart on Ubuntu 22.04?

Set permissions for the storage and image folders to 755, and for the config.php files to 644. Use the following commands: sudo chmod 755 /path/to/storage/folder, sudo chmod 755 /path/to/image/folder, sudo chmod 644 /path/to/config.php.

How do I secure my OpenCart installation on Ubuntu 22.04?

Keep your Ubuntu server up to date with security patches. Enable a firewall and only open necessary ports. Use strong passwords and regularly backup your OpenCart files and database.

Can I use SSL/TLS encryption with OpenCart on Ubuntu 22.04?

Yes, you can secure your OpenCart website with an SSL/TLS certificate. Install and configure the certificate on your web server for encrypted communication.

How can I upgrade OpenCart to a newer version on Ubuntu 22.04?

Before upgrading, backup your website files and database. Download the latest version of OpenCart, extract the files, and replace the existing ones. Follow the upgrade instructions provided by OpenCart.


We hope this detailed tutorial helped you understand how to install OpenCart on Ubuntu 22.04.

If you have any suggestions or queries, kindly leave them in the comments section.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.