In this tutorial, you’ll learn that how to install and configure OpenCart E-commerce platform on Ubuntu 20.04. As the name indicates, opencart provides the e-commerce platform for online business and companies to operate their stores online. Opencart is very powerful, convinient and great management program used to manage multiple stores online. Here we’ll list some features of the OpenCart.
Salient Features of OpenCart
- Administrator Dashboard: All the important information available at a glimpse.
- User Management: OpenCart allows you to set advanced user privileges and separate access for user groups and users.
- Multi-Store: Manage multiple stores from one admin interface.
- Options, attributes: No matter the case OpenCart offers a solution on adding extra important product variables.
To install the OpenCart on Ubuntu, you need to fulfil the following requirements.
Requirements
- Web Server(Apache, Nginx)
- PHP(5.4 or greater)
- Database (MySQLi recommended)
- Curl enabled
Let’s move towards the installation process.
Step 1: Update Your System
As usual we do, update your system and upgrade your system to have the latest packages installed.
sudo apt update && sudo apt upgrade
Install curl and some additional packages by hitting below command in your terminal.
sudo apt install vim git unzip curl -y
Step 2: Install MariaDB Database
To install MariaDB on your Ubuntu system, follow the below guide. As I’ve already installed so I’m going to proceed further. After the installation of MariaDB database, create the database as seen below:
How To Install MariaDB on Ubuntu 20.04
sudo mysql -u root -p Enter password: MariaDB [(none)]> CREATE DATABASE opencart; MariaDB [(none)]> CREATE USER 'opencart'@'localhost' IDENTIFIED BY 'Your_Password'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON opencart . * TO 'opencart'@'localhost'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> exit;
Step 3: Install & Configure Web Server & PHP
Visit the below link to install Nginx along with PHP-FPM on Ubuntu 20.04. After the installation finished, do the further changes given below.
How To Install Nginx With PHP-FPM on Ubuntu 20.04
After the installation finished, edit the /etc/php/7.4/fpm/php.ini and set up the memory limit to 512M and also setup your timezone.
Verify the PHP-FPM services.
sabir@Ubuntu20:~$ sudo systemctl status php7.4-fpm.service ● php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php7.4-fpm.service; enabled; vendor p> Active: active (running) since Fri 2020-08-28 07:44:33 PKT; 25min ago Docs: man:php-fpm7.4(8) Process: 1178 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /ru> Main PID: 902 (php-fpm7.4) Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0re> Tasks: 3 (limit: 3449) Memory: 19.0M CGroup: /system.slice/php7.4-fpm.service ├─ 902 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf) ├─1176 php-fpm: pool www └─1177 php-fpm: pool www اگست 28 07:44:16 Ubuntu20 systemd[1]: Starting The PHP 7.4 FastCGI Process Man> اگست 28 07:44:33 Ubuntu20 systemd[1]: Started The PHP 7.4 FastCGI Process Mana> lines 1-16/16 (END)
Step 4 Clone OpenCart’s files & Configure Nginx
Now, create the directory to store the files that will be served by the Web Server when requested. By default the location of files is root directory but you can select your desired one according to your needs.
sudo mkdir /var/www/html/commerce/ && cd /var/www/html/commerce/ sudo git clone https://github.com/opencart/opencart.git
When the git command finished, a new directory will be created at /var/www/html/commerce named opencart. The files will be cloned at this directory from github.
Once, it finished go to the upload & upload/admin directory to rename them as shown below.
cd /var/www/html/commerce/opencart/upload/ sudo mv config-dist.php config.php cd /var/www/html/commerce/opencart/upload/admin sudo mv config-dist.php config.php
Configure Nginx
Do the following changes listed below to server Nginx with OpenCart. Navigate to the sites-enabled directory, back up the default file & create new with the new config.
cd /etc/nginx/sites-enabled/
sudo mv default /tmp
sudo nano /etc/nginx/sites-enabled/opencart.conf
For users having FQDN, it is recommend to replace example.com with it. And add the following data into the file.
server { listen 80 default_server; listen [::]:80 default_server server_name example.com; root /var/www/html/commerce/opencart/upload; index index.php index.htm index.html; location / { try_files $uri $uri/ /index.php?$args; } location ~ .php$ { fastcgi_pass unix:/run/php/php7.4-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)(/.+)$; } }
Step 5: Change OpenCart’s Files Permissions
Run the below commands to give OpenCart proper permissions.
sudo chown -R www-data:www-data /var/www/html/commerce/
sudo chmod -R 755 /var/www/html/commerce/
sudo systemctl restart nginx php7.4-fpm
Step 6: Setup OpenCart via Web Interface
Open your favorite browser andtype the domain name or IP of the web server to access OpenCart Web interface. Then you’ll see the welcome page to accept the license agreement. Accept it to continue.
On the next page, you’ll see the information about the server configuration. If everything is okay click on the “Continue” button.
Then, provide the Database details as provided in the starting of the installation. Also provide the admin credentials for administrative privileges. Finally hit “Continue”.
As of successful installation, you’ll see the message to delete your installation directory to finish the installation. Simply delete the directory and press on “Login to your Administration” button.
Step 7: Advanced steps to Operate OpenCart
Now, login to the dashboard and you’ll see an alert to move the storage directory out of the public directory. Hit “Move” button to perform the action. Then you’ll see the dashboard as seen below:
And then you can perform different steps, do different settings and manage your online store. For more detailed documentation, visit the official page of OpenCart.
So, this is how you can install and configure OpenCart on Ubuntu 20.04.
Hii..
I m Using on AWS Ubuntu 20.04.
If I havent domain. I want to use via instance ip address so in
“”sudo nano /etc/nginx/sites-enabled/opencart.conf”
server {
listen 80 default_server;
listen [::]:80 default_server
server_name example.com;
root /var/www/html/commerce/opencart/upload;
index index.php index.htm index.html;
location / { try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
fastcgi_pass unix:/run/php/php7.4-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)(/.+)$;
}
}
what replace with in example.com.
thanks in Advance.