Article

Table of Contents
Theme:
Was this article helpful?
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles!

Install OpenCart on Ubuntu 20.04

Author: Thomas Rakwach

Last Updated: Wed, Nov 24, 2021
Business Server Apps Ubuntu

Introduction

OpenCart is a free and open-source online store management software based on PHP that manages multiple online stores from a single administrative dashboard with a modern, responsive interface. It has modules to manage inventory, orders, sales reports, discounts, payments, customers, marketing tools, and its functionality is extensible with professionally-written extensions and plugins. This article describes how to install OpenCart on Ubuntu 20.04 server.

Prerequisites

  • Deploy a fully updated Vultr Ubuntu 20.04 Server.
  • Create a non-root user with sudo access.
  • PHP version 5.4 and above.
  • Web Server (Apache suggested).

1. Install Required Packages

  1. SSH to your server as a non-root user with sudo access.
  2. Update system package list to update all packages to the latest available versions.

    $ sudo apt update
    
  3. The latest versions of OpenCart only support PHP version 8.0. Ubuntu 20.04 does not contain PHP 8.0 in its default repository list. To install it, add the PHP repository to the APT.

    Add ppa:ondrej/php repository.

    $ sudo apt -y install software-properties-common
    
    $ sudo add-apt-repository ppa:ondrej/php
    
  4. Update system package manager.

    $ sudo apt update
    
  5. Install PHP 8.0 and more modules.

    $ sudo apt install apache2 mysql-server php8.0 libapache2-mod-php8.0 php8.0-mysql php8.0-curl php8.0-xml php8.0-zip php8.0-gd php8.0-cli php8.0-fpm libapache2-mod-fcgid wget unzip -y
    
  6. Enable Apache2 with PHP-FPM.

    $ sudo a2enmod proxy_fcgi setenvif
    
    $ sudo a2enconf php8.0-fpm
    
  7. Restart Apache service.

    $ sudo systemctl restart apache2
    

2. Create OpenCart Database

  1. Log in to MySQL shell. On password prompt, just press ENTER to continue.

    $ sudo mysql -u root -p
    
  2. Crate a database called opencart.

    CREATE DATABASE opencart;
    
  3. Crate a user called opencart with a password StrongPassword.

    CREATE USER 'opencart'@'localhost' IDENTIFIED BY 'StrongPassword';
    
  4. Grant all database privileges to the user.

    GRANT ALL PRIVILEGES ON opencart . * TO 'opencart'@'localhost';
    
  5. Save the changes.

    FLUSH PRIVILEGES;
    
  6. Exit the shell.

    exit;
    

3. Install OpenCart

  1. Download the latest OpenCart version.

    $ wget https://github.com/opencart/opencart/archive/refs/heads/master.zip
    
  2. Unzip the downloaded file.

    $ sudo unzip master.zip
    
  3. Create the installation directory /var/www/html/opencart.

    $ sudo mkdir /var/www/html/opencart
    
  4. Move the unzipped files to the installation directory.

    $ sudo mv opencart-master/* /var/www/html/opencart
    
  5. Copy OpenCart configuration files.

    $ 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}
    
  6. Change ownership of the installation directory.

    $ sudo chown -R www-data:www-data /var/www/html/opencart
    
  7. Change access permissions for the installation directory.

    $ sudo chmod -R 755 /var/www/html/opencart
    

4. Configure Apache2

  1. Create a new Apache virtual host file named opencart.conf.

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

    Add the following code to the file. Save and close the file.

    <VirtualHost *:80>
        ServerAdmin admin@example.com
        DocumentRoot /var/www/html/opencart/upload/
        ServerName example.com
        ServerAlias www.example.com
    
        <Directory /var/www/html/opencart/upload/>
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    
        ErrorLog /var/log/apache2/example.com-error_log
        CustomLog /var/log/apache2/example.com-access_log common
    </VirtualHost>
    
  2. Disable Apache default configuration file.

    $ sudo a2dissite 000-default.conf
    
  3. Enable OpenCart Apache configuration file.

    $ sudo a2ensite opencart.conf
    
  4. Enable Apache rewrite mode.

    $ sudo a2enmod rewrite
    
  5. Restart Apache service.

    $ sudo systemctl restart apache2
    

5. Access OpenCart Web Interface

To access the OpenCart Web Interface, go to your browser and visit http://Server_IP/. For example:

http://192.0.2.10/

Conclusion

You have installed OpenCart on your server. Access the Installation Wizard screen to complete installation by connecting to the database you created, creating an administrator account and other settings. You can now access the Dashboard and configure it to begin managing your business.

More Information

To learn more about using OpenCart, go to the official documentation page.

Want to contribute?

You could earn up to $600 by adding new articles