Atlantic.Net Blog

How to Install OpenCart on Ubuntu 20.04

Hitesh Jethva
by Atlantic.Net (272 posts) under Dedicated Server Hosting, Tutorials
0 Comments

OpenCart is an open-source, PHP-based e-commerce platform used to host your online store on the Internet. It provides a user-friendly web interface that makes it easier to manage products, orders, and users in a seamless manner. OpenCart offers a lot of plugins that help you to extend the platform’s functionality and includes features like user management, multi-store functionality, affiliates, discounts, multiple payment gateways, product reviews, and more.

In this post, we will explain how to install and configure the OpenCart e-commerce platform on Ubuntu 20.04.

Prerequisites

  • A fresh Ubuntu 20.04 server on the Atlantic.Net Cloud Platform
  • A root password configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Ubuntu 20.04 as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your Ubuntu 20.04 server, run the following command to update your base system with the latest available packages.

apt-get update -y

Step 2 – Install Nginx, PHP, and MariaDB

First, install the Nginx web server and MariaDB database with the following command:

apt-get install nginx mariadb-server -y

OpenCart only supports PHP version 8.0, so you will need to install PHP version 8.0 on your server. By default, PHP 8.0 is not included in the Ubuntu default repository, so you will need to add the PHP repository to the APT.

First, install the required dependencies using the following command:

apt-get install software-properties-common git -y

Next, add the PHP repository with the following command:

add-apt-repository ppa:ondrej/php

Once the repository is added, install the PHP 8.0 with all required extensions using the following command:

apt-get install php8.0 php8.0-fpm php8.0-mysql php8.0-curl php8.0-gd php8.0-cli php8.0-zip -y

The above command will also install the Apache package to your server, so you will need to remove it and stop the service.

apt-get remove apache2
systemctl stop apache2

Next, start the Nginx, MariaDB, and PHP-FPM services and enable them to start at system reboot:

systemctl start nginx mariadb php8.0-fpm
systemctl enable nginx mariadb php8.0-fpm

Step 3 – Create a Database for OpenCart

OpenCart uses the MariaDB as a database backend, so you will need to create a database and user for OpenCart.

First, log in to MySQL using the following command:

mysql

Once logged in, create a database and user using the following command:

CREATE DATABASE opencart;
CREATE USER 'opencart'@'localhost' IDENTIFIED BY 'password';

Next, grant all privileges to the OpenCart database:

GRANT ALL PRIVILEGES ON opencart.* TO 'opencart'@'localhost';

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

FLUSH PRIVILEGES;
EXIT;

Step 4 – Install OpenCart

Next, download the latest version of OpenCart to the Nginx web root directory:

cd /var/www/html
git clone https://github.com/opencart/opencart.git

Once the download is completed, change the directory to upload and rename the config file:

cd opencart/upload
mv config-dist.php config.php

Next, change the directory to admin and rename the config file:

cd admin
mv config-dist.php config.php

Next, set proper ownership to the OpenCart directory:

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

Step 5 – Configure Nginx for OpenCart

Next, create an Nginx virtual host configuration file to host OpenCart:

nano /etc/nginx/conf.d/opencart.conf

Add the following lines:

server {
        listen 80;
	server_name opencart.example.com;
	root /var/www/html/opencart/upload;
	index index.php index.htm index.html;
	location / { try_files $uri $uri/ /index.php?$args;
	}
 	location ~ .php$ {
 	fastcgi_pass unix:/run/php/php8.0-fpm.sock;
 	fastcgi_index index.php;
 	fastcgi_read_timeout 240; 
	fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 	include fastcgi_params; 
	fastcgi_split_path_info ^(.+.php)(/.+)$; 
	}
}

Save and close the file, then verify the Nginx for any configuration errors:

nginx -t

Sample output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Finally, restart the Nginx service to apply the changes:

systemctl restart nginx

Step 6 – Access OpenCart Web Interface

Now, open your web browser and access OpenCart using the URL http://opencart.example.com. You should see the following page:
Opencart welcome Page
Click on CONTINUE to accept the License. You should see the following page:
Opencart Requirement Check Page
Make sure all the PHP extensions are installed, then click on CONTINUE. You should see the following page:
Opencart Database Setup Page
Provide your database information and admin user details and click on CONTINUE. Once the installation has been completed, you should see the following page:
Opencart Installation Finish Page
Now, remove the install directory using the following command:

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

Next, click on the LOGIN TO YOUR ADMINISTRATION. You should see the following page:
Opencart Login Page
Provide your admin username and password and click on the Login. You should see the OpenCart dashboard on the following page:
Opencart Dashboard Page

Conclusion

Congratulations! Your OpenCart platform is now ready to use. You can now deploy your own online store using OpenCart. Get started on dedicated hosting from Atlantic.Net.

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources