Write Review

OpenCart is a free web-based shopping cart system written in PHP. The e-commerce platform works pretty well on any Ubuntu server running a web server and MySQL or OpenCart is released under the GNU General public license

Since its early development in 1998, OpenCart continues to server thousands of online stores because it is easy to develop, use and configure. Also there are lots of forums and online articles that address customers’ pain points when using the software.

OpenCart has received a lot of support from developers who continue to release thousands of modules and stunning themes that you can use to run your shop.  The shopping cart also supports a multi-store environment and is SEO friendly.

In this guide, we will see the basic steps of installing and running OpenCart on your Ubuntu 18.04 server.


  • An Ubuntu 18.04 VPS Plan
  • A non-root user with sudo privileges

Step 1:
Update your server package repository

When installing any software on Ubuntu, it is advisable to run the command below to update the packages information:

$ sudo apt-get update

Step 2:
Install Apache

Apache is a web-server that has a lion-market share. It is very secure and comes with dozens of great features (e.g. mod_rewrite, SSL support, Virtual hosts) and these makes it fit for running OpenCart e-commerce software.

To install Apache, run the command below:

$ sudo apt-get install apache2

Step 3:
Install Maria Db

MariaDb is an open source database application that is quite flexible, secure and easy to use. We will use it on the OpenCart website to store data related to products, customers, payment methods, tax rates, shipping methods e.t.c.

Run the command below to install MariaDb on your Ubuntu 18.04 server.

$ sudo apt-get install mariadb-server mariadb-client

Then, secure your MariaDb instance by typing the following:

$ sudo mysql_secure_installation

The command above allows you to remove anonymous login, test databases and set a strong password for root user. It also gives you an option to disable remote access to your MariaDb server for security purposes. Press Y and Enter when prompted to change an option.

Create OpenCart database and user

Log in to your MariaDB server using the command below. You will be prompted to enter a password:

$ sudo mysql  -u root -p

Then run the following SQL commands to create a database and a user:

$ CREATE USER 'ocuser'@'localhost' IDENTIFIED BY 'PASSWORD';

Remember to replace ‘PASSWORD’ with the correct value.

Step 4:
Install PHP and common modules

OpenCart is written in PHP. So we need to install it as the server side scripting language for our OpenCart website using the commands below:

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

Then, restart apache by typing the command below:

$ sudo systemctl restart apache2

Step 5:
Download the latest release of OpenCart

Move to the /tmp directory and download the latest stable release of OpenCart by typing the commands below:

$ cd /tmp
$ wget https://github.com/opencart/opencart/releases/download/

Unzip contents

Once, ‘’ is downloaded, unzip it by typing the following:

$ sudo apt install unzip
$ unzip

The content of the ‘’ will be unzipped to ‘/tmp/upload’ folder

Move the directory content to the root of your website using the command below:

$ sudo mv upload/ /var/www/html/opencart

Step 6:
Configure Opencart

Copy the necessary OpenCart configuration files using by typing:

$ sudo cp /var/www/html/opencart/config-dist.php /var/www/html/opencart/config.php


$ sudo cp /var/www/html/opencart/admin/config-dist.php /var/www/html/opencart/admin/config.php

Step 7:
Change the directory ownership

The OpenCart directory needs to be writable by the Apache web server, hence we can change the directory ownership by typing the following:
Then we need to set the right permissions to the directory with the commands below:

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

Step 8:
Enable rewrite module

OpenCart requires mod_rewrite for rewriting urls. Run the command below to enable the module and restart Apache

$ sudo a2enmod rewrite
$ sudo systemctl restart apache2

Step 9:
Finalizing the configuration

You can now finalize the setup by visiting your domain name or IP address on the browser. For instance if your IP address is visit on your browser and you will see a setup screen like the one shown below:

Read the agreement and click ‘CONTINUE’ to proceed

The next screen will display the pre-installation information to make sure your installation is setup as required.

Finally, you will be required to select a DB driver (choose PDO) and enter the database values that you created above as shown below. You will also need to create a username and a password for login to your OpenCart admin section.


That is how to install OpenCart Shopping Cart on your Ubuntu 18.04 server. You can now start setting up your online store by creating a catalog, shipping rates and payment details. For the best experience, you should run OpenCart on a domain name that has SSL certificate installed. We hope you enjoyed reading the guide.


Check out the top 3 Ecommerce hosting services:

Was this article helpful?