Dec 25, 2023 5 min read

How to Install Opencart on Ubuntu 20.04

Install Opencart on Ubuntu 20.04 with our step-by-step tutorial. It is a popular, SEO-friendly open-source eCommerce platform.

Install Opencart on Ubuntu 20.04
Install Opencart on Ubuntu 20.04
Table of Contents

Choose a different version or distribution

Introduction

Before we begin talking about how to install Opencart on Ubuntu 20.04, let’s briefly understand – What is Opencart?

Opencart is a popular, SEO-friendly open-source eCommerce platform. With its user-friendly interface, customizable themes, and secure payment gateways, Opencart offers a cost-effective solution for businesses to launch and manage online stores.

Its flexibility and scalability make it ideal for launching and managing an online business, while built-in SEO features enhance search engine rankings and increase visibility. Start your eCommerce journey with Opencart today.

In this tutorial, you will install Opencart in an independent environment on Ubuntu 20.04. We will also address a few FAQs on how to install Opencart on Ubuntu 20.04.

Advantages of Opencart

  1. User-friendly interface: Opencart offers an intuitive and easy-to-use interface, making it simple for merchants to manage their online stores.
  2. Customizability: With a wide range of themes and extensions, Opencart allows businesses to customize their online stores according to their unique branding and requirements.
  3. Extensive product options: Opencart supports unlimited products and categories, enabling businesses to showcase their entire product range effectively.
  4. Secure payment gateways: Opencart integrates with popular payment gateways, ensuring secure and hassle-free transactions for both merchants and customers.
  5. SEO-friendly: Opencart is designed with built-in SEO features, making it easier for businesses to optimize their online stores for better search engine rankings and increased organic traffic.

Prerequisites

  • Ubuntu 20.04 server.
  • access to the server through SSH.
  • Installed LAMP stack. If it isn't already installed, you can do it by using this tutorial.
  • SSL-secured domain mapping with server IP.
    (Optional)

How to Install Opencart on Ubuntu 20.04

There are various ways to install Opencart. One-click setup is available with some hosting services, including AWS, Digital Ocean, and Google Cloud. You can use Softaculous to install Opencart if you are using cPanel.

This article includes comprehensive manual installation instructions that are applicable to practically all Linux-based Ubuntu servers.

Step 1: Update Software Packages

SSH into the Ubuntu server first, then update the software packages.

sudo apt update
sudo apt upgrade

Step 2: On the Ubuntu Server, install LAMP

You can find thorough instructions in this post if you haven't configured the LAMP stack yet. I'll share some fast installation instructions below, though.

sudo apt install apache2 mysql-server unzip -y

The most recent version of Opencart requires PHP 8; you can obtain PHP 8 by reading this article. Execute the following command to install PHP 8.

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.0 libapache2-mod-php8.0 php8.0-zip php8.0-curl php8.0-gd php8.0-mysql -y

Run the command below to enable Apache with PHP-FPM.

sudo apt install php8.0-fpm libapache2-mod-fcgid

PHP-FPM is not enabled by default; perform the following command to enable it.

sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.0-fpm

Step 3: Create MySQL database

Set up a database for the installation of Opencart by logging into the MySQL console and doing so.

sudo mysql

Create a database, user after logging onto the MySQL shell.

mysql> CREATE DATABASE opencartDB;
mysql> CREATE USER 'opencart'@'localhost' IDENTIFIED BY 'your_password';
mysql> GRANT ALL PRIVILEGES ON opencart . * TO 'opencart'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;

Step 4: Download Opencart

Use wget under /tmp directory to get the most recent version of Opencart, then unzip the downloaded file.

cd /tmp
wget https://github.com/opencart/opencart/archive/refs/heads/master.zip

Once Opencart has been downloaded, use unzip to open the file.

unzip master.zip
sudo mv /tmp/opencart-master/ /var/www/html/opencart

Step 5: Configure Document root

To copy the configuration files, run the cp command:

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}

Step 6: Update the File Permissions of the Document root

Use the following commands to change the document root's file and directory permissions.

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

Step 7: Create apache configuration host file

create opencat.conf in sites-available directory:

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

Paste this configuration inside it:

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

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

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

Next, enable open cart configuration and disable default conf:

sudo a2ensite opencart.conf
sudo a2dissite 000-default

Now, reload your apache

sudo systemctl reload apache2

Step 8: Install Opencart through the Browser

To continue installation, visit your domain name or server IP address on the browser. http://domain_or_ip/

License Agreement

Install OpenCart on Ubuntu 20.04 by clicking Continue after checking the server settings and ensuring that all necessary PHP extensions are installed on the server.

Click on Continue

As soon as the database information was filled out for installation, an administrator account was established with the appropriate username and password.

Configuration

Click next to finish the installation after filling out all the necessary information. You will be prompted to remove the installation directory after the installation is finished.

remove the installation directory
sudo rm -rf /var/www/html/opencart-master/upload/install/

You're done when you remove the installation directory from the document root. You can now access the website on the browser.

yourdomainname.com or server_ip
IP Address

FAQs to Install Opencart on Ubuntu 20.04

Which web server should I use with OpenCart on Ubuntu 20.04?

OpenCart is compatible with popular web servers like Apache or Nginx. Either can be used as per your preference.

What database should I use for OpenCart on Ubuntu 20.04?

OpenCart supports various databases, but it's recommended to use MariaDB or MySQL for optimal performance.

How do I install and configure the required dependencies for OpenCart?

You can install the necessary dependencies, like PHP and necessary PHP extensions, using the package manager and then configure them in the web server's configuration files.

Can I use OpenCart on a shared hosting environment?

Yes, OpenCart can be used on shared hosting, provided it meets the required PHP and database version compatibility.

Is it necessary to have an SSL certificate for OpenCart on Ubuntu 20.04?

While not mandatory, having an SSL certificate is highly recommended for secure transactions and building customer trust.

Can I migrate my existing OpenCart installation to Ubuntu 20.04?

Yes, you can migrate your OpenCart installation to Ubuntu 20.04 by taking a backup of the database, transferring the files, and reconfiguring the necessary settings.

Where can I find support if I encounter issues during the installation process?

You can seek support from the OpenCart community forums, official documentation, or consider hiring a professional for assistance with the installation and setup process.

Conclusion

You now know how to install OpenCart on Ubuntu 20.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.