How to Install Opencart on Ubuntu 19.04

Installation of OpenCart on Ubuntu 19.04

Open cart is a free and open source e-commerce platform for online shopping application and it provides a professional and reliable foundation from which we can build a successful online store. This foundation to use, to shop a variety of users and ranging from seasoned web developers looking for a user-friendly interface for using the shop owners will just launch their online business. This tutorial covers the installation of OpenCart on Ubuntu 19.04

Requirements for OpenCart:

Apache

MySQL

PHP and its module

(php php-xml php-mysql php-mbstring php-zip php-soap php-curl php-gd php-ldap php-imap php-common php-dev libmcrypt-dev php-pear)

Installation procedure

Before you begin, ensure that you check the version of Ubuntu you are using by running the following command.

root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 19.04
Release:	19.04
Codename:	disco

configure the MySQL database. Log into MySQL as a root user and make the necessary settings.

root@linuxhelp:~# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.26-0ubuntu0.19.04.1 (Ubuntu)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database opendb;
Query OK, 1 row affected (0.33 sec)

mysql> create user 'openuser'@localhost identified by 'Linuxc#45';
Query OK, 0 rows affected (0.76 sec)

mysql> grant all privileges on opendb.* to 'openuser'@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.76 sec)

mysql> exit
Bye

Once the database configuration is done, download the OpenCart installation package by using the wget command.

root@linuxhelp:~# wget https://github.com/opencart/opencart/archive/master.zip
--2019-05-22 01:59:57--  https://github.com/opencart/opencart/archive/master.zip
Resolving github.com (github.com)... 192.30.253.113, 192.30.253.112
Connecting to github.com (github.com)|192.30.253.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/opencart/opencart/zip/master [following]
--2019-05-22 01:59:58--  https://codeload.github.com/opencart/opencart/zip/master
Resolving codeload.github.com (codeload.github.com)... 192.30.253.121
Connecting to codeload.github.com (codeload.github.com)|192.30.253.121|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/zip]
Saving to: ‘master.zip’

master.zip                      [      <=>                                  ]  19.77M  1.11MB/s    in 19s     

2019-05-22 02:00:19 (1.04 MB/s) - ‘master.zip’ saved [20735392]

Once the download is completed extract the downloaded package using unzip command.

root@linuxhelp:~# unzip master.zip -d opencart
Archive:  master.zip
c29a043ba2f26370f114b30217cc42e967616078
   creating: opencart/opencart-master/
   creating: opencart/opencart-master/.github/
   creating: opencart/opencart-master/.github/ISSUE_TEMPLATE/
  inflating: opencart/opencart-master/.github/ISSUE_TEMPLATE/bug_report.md  
  inflating: opencart/opencart-master/CHANGELOG.md  
  inflating: opencart/opencart-master/CHANGELOG_AUTO.md  
  inflating: opencart/opencart-master/README.md  
  inflating: opencart/opencart-master/build.xml  
  inflating: opencart/opencart-master/composer.json  
  inflating: opencart/opencart-master/composer.lock  
.
.
  inflating: opencart/opencart-master/upload/system/storage/vendor/zoujingli/wechat-php-sdk/Wechat/WechatScript.php  
  inflating: opencart/opencart-master/upload/system/storage/vendor/zoujingli/wechat-php-sdk/Wechat/WechatService.php  
  inflating: opencart/opencart-master/upload/system/storage/vendor/zoujingli/wechat-php-sdk/Wechat/WechatUser.php  
  inflating: opencart/opencart-master/upload/system/storage/vendor/zoujingli/wechat-php-sdk/composer.json  
  inflating: opencart/opencart-master/upload/system/storage/vendor/zoujingli/wechat-php-sdk/include.php  
  inflating: opencart/opencart-master/upload/system/storage/vendor/zoujingli/wechat-php-sdk/test.php  

Move the OpenCart directory to apache root directory.

root@linuxhelp:~# mv opencart-master /var/www/opencart

Set the ownership and permission for OpenCart by using the following command.

root@linuxhelp:~# chown -R www-data.www-data /var/www/opencart
root@linuxhelp:~# chmod -R 755 /var/www/opencart

Configure the virtualhost for accessing the Opencart.

root@linuxhelp:~# vim /etc/apache2/sites-available/opencart.conf
<Virtualhost *:80>
        Servername www.linuxhelp1.com
        Documentroot /var/www/opencart/upload
<directory /var/www/opencart/upload>
allowoverride all
allow from all
</directory>
</Virtualhost>

Disable the default site access.

root@linuxhelp:~# a2dissite 000-default.conf
Site 000-default disabled.
To activate the new configuration, you need to run:
  systemctl reload apache2

Enable the site access for accessing the OpenCart.

root@linuxhelp:~# a2ensite opencart.conf
Enabling site opencart.
To activate the new configuration, you need to run:
  systemctl reload apache2

Enable the rewrite module.

root@linuxhelp:~# a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
  systemctl restart apache2

Restart the apache service by using the following command.

root@linuxhelp:~# systemctl restart apache2

Switch to your browser and enter the domain name.

Accept the License agreement to use the Opencart.

Check out the preinstallation requirements.

Now make changes as follows.

root@linuxhelp:~# cd /var/www/opencart
root@linuxhelp:/var/www/opencart# cd upload

List out and Rename the filename.

root@linuxhelp:/var/www/opencart/upload# ls

Admin catalog config-dist.php image index.php install php.ini system.

root@linuxhelp:/var/www/opencart/upload# mv config-dist.php config.php

Enter into the admin directory.

root@linuxhelp:/var/www/opencart/upload# cd admin
root@linuxhelp:/var/www/opencart/upload/admin# ls
config-dist.php  controller  index.php  language  model  view

Rename the file name.

root@linuxhelp:/var/www/opencart/upload/admin# mv config-dist.php config.php

Restart the apache service by using the following command.

root@linuxhelp:/var/www/opencart/upload/admin# systemctl restart apache2

Configure the database detail and Admin account setup. Now the installation setup is complete and to access OpenCart admin panel click on login as admin.

Now login with Admin user credential

After successful login, you will see the admin dashboard of OpenCart.

With this, the method to install Opencart on Ubuntu 19.04 comes to an end.

FAQ
Q
How to resolve 404 error on Opencart Web console?
A
Check the document root are correctly pointed in VirtualHost.
Q
What is OpenCart?
A
OpenCart is a free and open source e-commerce platform for online shopping application and it provides a professional and reliable foundation from which we can build a successful online store. This foundation to use, to shop a variety of users and ranging from seasoned web developers looking for a user-friendly interface for using the shop owners will just launch their online business.
Q
Is there any alternative for the OpenCart software?
A
The following are the alternatives for OpenCart software:
PrestaShop
WooCommerce
Shopify
Q
How to have host entry for the OpenCart domain?
A
To have a host entry for the OpenCart do the following:
# /etc/hosts
Q
How to create Custom error and access log for Opencart?
A
Enable custom access and error log in Opencart by enabling the following in Opencart virtual host:
Errorlog /var /log /opencartdomain/error_log
Customlog /var /log /opencartdomain/access_log