How to Install OpenCart on Ubuntu 16.04

Alibaba Cloud
5 min readJun 27, 2019

By Hitesh Jethva, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

OpenCart is a free, open source, popular and widely used php-based online shopping cart software solution that can be used to setup and run your own online store at a minimal cost. It is specially disigned for small and medium-size businesses. It is simple, easy to install and comes with many add-ons, extensions that enable you to create your own online business and participate in e-commerce at a minimal cost. You can easily manage multiple stores from web-based interface, set products to appear on different stores and choose a different theme for each store.

Alibaba Cloud provides a ready-to-use OpenCart server in the Marketplace, but you can also install your own on for more customization. In this tutorial, we will be installing and configuring OpenCart on an Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 16.04 server.


  • A fresh Alibaba Cloud Ubuntu 16.04 instance.
  • A static IP address is set up in your instance.
  • A root password is set up to your instance.

Launch Alibaba Cloud ECS Instance

First, Login to your Alibaba Cloud ECS Console. Create a new ECS instance, choosing Ubuntu 16.04 as the operating system with at least 2GB RAM. Connect to your ECS instance and log in as the root user.

Once you are logged into your Ubuntu 16.04 instance, run the following command to update your base system with the latest available packages.

apt-get update -y

Install LAMP Server

OpenCart runs on web server, writen in PHP and uses MariaDB to store their data. So you will need to install Apache, MariaDB, PHP and Other PHP libraries to your server. You can install all of them by running the following command:

apt-get install apache2 mariadb-server php7.0 libapache2-mod-php7.0 php7.0-common php7.0-mbstring php7.0-xmlrpc php7.0-soap php7.0-gd php7.0-xml php7.0-intl php7.0-mysql php7.0-cli php7.0-mcrypt php7.0-ldap php7.0-zip php7.0-curl unzip wget git -y

Once all the packages are installed, you will need to make some changes in php.ini file:

nano /etc/php/7.0/apache2/php.ini

Make the following changes:

memory_limit = 512M
upload_max_filesize = 150M
max_execution_time = 360
date.timezone = Asia/Kolkata

Save and close the file, when you are finished.

Configure MariaDB

Next, you will need to harden MariaDB installation. You can do this by running the following script:


This script will set the root password, remove anonymous users, disallow root login and remove test database as shown below:

Enter current password for root (enter for none):
Set root password? [Y/n]: N
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

Once the MariaDB is secured, login to MariaDB shell:

mysql -u root -p

Enter your root password, then create a database and user for OpenCart:

MariaDB [(none)]> CREATE DATABASE opencartdb;
MariaDB [(none)]> CREATE USER 'opencartuser'@'localhost' IDENTIFIED BY 'password';

Next, grant all the privileges to the OpenCart with the following command:

MariaDB [(none)]> GRANT ALL ON opencartdb.* TO 'opencart'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

Next, flush the privileges and exit from the MariaDB shell with the following command:

MariaDB [(none)]> EXIT;

Install OpenCart

First, you will need to download the latest version of OpenCart from Git repository. You can download it with the following command:


Once the download is completed, extract the downloaded file with the following command:


Next, copy the upload directory to the Apache web root directory and give proper permissions with the following command:

cp -r opencart-master/upload /var/www/html/opencart
chown -R www-data:www-data /var/www/html/opencart/
chmod -R 755 /var/www/html/opencart/

Next, copy sample config file with the following command:

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

Configure Apache for OpenCart

Next, you will need to create an Apache virtual host file for OpenCart. You can do this with the following command:

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

Add the following lines:

<VirtualHost *:80>
DocumentRoot /var/www/html/opencart/
<Directory /var/www/html/opencart/>
Options FollowSymlinks
AllowOverride All
Order allow,deny
allow from all
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

Save and close the file. Then, enable Apache virtual host with the following command:

a2ensite opencart.conf

Next, enable an Apache rewrite module and reload Apache service with the following command:

a2enmod rewrite
systemctl restart apache2

Access OpenCart Web Interface

Now, open your web browser and type the URL You will be redirected to the OpenCart license agreement as shown below:

Accept the license agreement and Click on the CONTINUE button. You should see the pre-installation check page:

Make sure all the required packages are installed. Then, click on the CONTINUE button. You should see the following page:

Here, provide your database name, database username, password, admin username and password. Then, click on the CONTINUE button. Once the installation has been completed, you should see the following page:

Now, click on LOGIN TO YOUR ADMINISTRATION button. You will be redirected to the OpenCart login page:

Now, provide your admin username and password. Then, click on the Login button. You should see the OpenCart default dashboard in the following image:

You can also access your online store by visiting the URL You should see the following page:

Next, you will need to delete the installation directory on the server.

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

Congratulations! You have successfully installed and configured OpenCart on Ubuntu 16.04 server. You can now easily deploy your own online store using OpenCart.

Original Source



Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website: