How to Install and Configure the latest OpenCart on Ubuntu 16.04 or 18.04

This post will guide you how to install and configure the latest version of OpenCart on your Ubuntu 16.04 or 18.04 Linux server. And this post will show you the following steps to install OpenCart on an ubuntu Linux server.

What is OpenCart?


OpenCart is an online store management system. It is PHP-based, using a MySQL database and HTML components. Support is provided for different languages and currencies. It is freely available under the GNU General Public License. By May 2016, 342,000 websites were using OpenCart.

OpenCart is a popular and opensource eCommerce content managment system, and it is developed by PHP language. you can use this platform to create and manage an online store. it is the best free and open-source eCommerce platofrm and everything you need to create, scale and run your business. OpenCart support the biggest eCommerce selections of modules and themes to expand your store functionality. you can easy manage products, customers, orders, taxes rules, coupon codes and more in OpenCart platform.

In this tutorial, you will see the basic steps of installing and configuring OpenCart on your ubuntu 16.04 or 18.04 server. you can also refer the below steps on Debian Linux.

ubuntu install opencart3

Prerequisites


  • A running Ubuntu Linux system or VM
  • You need to have a non-root user with sudo privileges
  • A FQDN Domain name that point to your IP address. Such as: mytest.com

Step1: Installing Apache


Before you begin to install packages on your Ubuntu system, you need to make sure that your system is up to date, so you need to run yum update command to update the APT index and upgrade all packages that can be updated.

$ sudo apt update
$ sudo apt upgrade

Then you can begin to install the Apache package with the following command:

$ sudo apt-get install apache2 libapache2-mod-php

Outputs:

devops@devops:~$ sudo apt-get install apache2 libapache2-mod-php
[sudo] password for devops:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.18.0-22 linux-headers-4.18.0-22-generic
linux-image-4.18.0-22-generic linux-modules-4.18.0-22-generic
linux-modules-extra-4.18.0-22-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom
The following NEW packages will be installed:
libapache2-mod-php
The following packages will be upgraded:
apache2 apache2-bin apache2-data apache2-utils
4 upgraded, 1 newly installed, 0 to remove and 56 not upgraded.
Need to get 1,413 kB of archives.
After this operation, 16.4 kB of additional disk space will be used.
Do you want to continue? [Y/n]
…..

Setting up libapache2-mod-php (1:7.2+60ubuntu1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Setting up apache2-utils (2.4.29-1ubuntu4.7) ...
Setting up apache2-bin (2.4.29-1ubuntu4.7) ...
Setting up apache2-data (2.4.29-1ubuntu4.7) ...
Processing triggers for systemd (237-3ubuntu10.23) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up apache2 (2.4.29-1ubuntu4.7) ...

Step2: Configuring Apache


Once Apache package is installed on your system, you need to create a basic configuration file for Apache, and it will set DocumentRoot variable to specify the location of your website files and set ServerName variable to specify what you domain name is. And you can create it by copying a default config file, and then modify it. Just do the following steps:

1# Run the following command to copy the default config file to use it as a template.

$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mytest.com.conf

2# edit the configuration file mytest.com.conf with vim text editor, and uncomment the ServerName line, and replace example.com with you domain name, and then update the remain lines as below:

install prestashop on ubuntu1

 

$ sudo vim /etc/apache2/sites-available/mytest.com.conf
ServerName mytest.com
ServerAdmin test@mytest.com
Documentroot /var/www/html/mytest.com

<Directory /var/www/html/mytest.com>
    AllowOverride All
</Directory>

3# you need to create the directory to store your website files with the following mkdir command:

$ sudo mkdir /var/www/html/mytest.com

4# you need to disable the default configuration file and enable the newly created one, mytest.com.conf, run the below command:

$ sudo a2dissite 000-default.conf
$ sudo a2ensite mytest.com.conf

Outputs:

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

devops@devops:~$ sudo a2ensite mytest.com.conf
Enabling site mytest.com.
To activate the new configuration, you need to run:
systemctl reload apache2

5# you also need to enable the mod_rewrite Apache module for PrestaShop with the following command:

$ sudo a2enmod rewrite

6# need to restart Apache service with the following command:

$ sudo systemctl restart apache2.service

Step3: Installing PHP


You need to install php package on your Ubuntu system for PrestaShop software. Just run the following command to install it:

$ sudo apt install php libapache2-mod-php

Ouputs:

devops@devops:~$ sudo apt install php libapache2-mod-php
[sudo] password for devops:
Reading package lists... Done
Building dependency tree
Reading state information... Done
libapache2-mod-php is already the newest version (1:7.2+60ubuntu1).
The following packages were automatically installed and are no longer required:
linux-headers-4.18.0-22 linux-headers-4.18.0-22-generic linux-image-4.18.0-22-generic linux-modules-4.18.0-22-generic linux-modules-extra-4.18.0-22-generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
php
0 upgraded, 1 newly installed, 0 to remove and 56 not upgraded.
Need to get 3,084 B of archives.
After this operation, 12.3 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu bionic/main amd64 php all 1:7.2+60ubuntu1 [3,084 B]
Fetched 3,084 B in 0s (14.6 kB/s)
Selecting previously unselected package php.
(Reading database ... 210189 files and directories currently installed.)
Preparing to unpack .../php_1%3a7.2+60ubuntu1_all.deb ...
Unpacking php (1:7.2+60ubuntu1) ...
Setting up php (1:7.2+60ubuntu1) ...

Then you still need to install other required PHP modules with the following command:

$ sudo apt install php7.2-common php7.2-cli php7.2-fpm php7.2-opcache php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-xsl php7.2-mbstring php7.2-zip php7.2-bcmath php7.2-soap

Outputs:

devops@devops:~$ sudo apt install php7.2-common php7.2-cli php7.2-fpm php7.2-opcache php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-xsl php7.2-mbstring php7.2-zip php7.2-bcmath php7.2-soap
Reading package lists... Done
Building dependency tree
Reading state information... Done
php7.2-cli is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-common is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-common set to manually installed.
php7.2-curl is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-gd is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-mysql is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-opcache is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-intl is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-mbstring is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-zip is already the newest version (7.2.19-0ubuntu0.18.04.1).
The following packages were automatically installed and are no longer required:
linux-headers-4.18.0-22 linux-headers-4.18.0-22-generic linux-image-4.18.0-22-generic linux-modules-4.18.0-22-generic linux-modules-extra-4.18.0-22-generic
Use 'sudo apt autoremove' to remove them.
Suggested packages:
php-pear
The following NEW packages will be installed:
php7.2-bcmath php7.2-fpm php7.2-soap php7.2-xsl
0 upgraded, 4 newly installed, 0 to remove and 56 not upgraded.
Need to get 1,550 kB of archives.
After this operation, 5,456 kB of additional disk space will be used.
Do you want to continue? [Y/n]

Step4: Installing MySQL or MariaDB


Now you can begin to install MySQL database management or MariaDB database to store data for your PrestaShop. Just run the following command to install it:

$ sudo apt install mariadb-server

Or

$ sudo apt install mysql-server mysql-client

Once the installation is completed, you’d better to run mysq_secure_installation script to secure your MySQL or MariaDB installation by running the following command:

$ sudo mysql_secure_installation

Step5: Creating Database and User


Once the Database installation is completed, and you need to create a database for your PrestaShop site, and create one mysql user.

Firstly, you need to log in to your MySQl shell by issue the following command:

$ sudo mysql -u root -p

Then run the following SQL statement to create a new database called myprestashop in the MySQL Shell prompt:

Mysql> create database myprestashop;

Outputs:

mysql> create database myprestashop;
Query OK, 1 row affected (0.00 sec)

Next, you need to create a MySQL username called mypres and you also need to grant the necessary permissions to this user account, just issue the following MySQL commands:

Mysq> create user 'mypres'@'localhost' identified by 'password';
Mysql> grant all on myprestashop.* to 'mypres'@'localhost';
Mysql> flush privileges;
Mysql> exit;

Outputs:

mysql> create user 'mypres'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)

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

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

Step6: Downloading the Latest OpenCart Package


Before installing OpenCart on your Ubuntu server, you need to download it from its official web site with wget command, type:

$ wget https://github.com/opencart/opencart/releases/download/3.0.2.0/3.0.2.0-OpenCart.zip

Then you need to extract the archive file into Apache2 root directory /var/www/html, type:

$ unzip 3.0.2.0/3.0.2.0-OpenCart.zip $ sudo mv upload/ /var/www/html/mytest.com

Step7: Installing OpenCart


Now you can begin to install and configure OpenCart on your server. Firstly, you need to run the below command to configure OpenCart, type:

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

then you need to set the correct permissions for your Apache root directory using the following command:

$ sudo chown -R www-data:www-data /var/www/html/mytest.com/$ sudo chmod -R 755 /var/www/html/mytest.com/

Next, you need to open your browser and type the following URL link to install OpenCart:

http://mytest.com/install/

or

http://IP_ADDRESS/install/

ubuntu install opencart1

then you need to enter the database information so that the installation can continue.

When you see the below page, it indicates that the installation of OpenCart is completed.

ubuntu install opencart2

Conclusion


You should know that how to install and configure OpenCart on your Ubuntu or Debian Linux. If you want to see more detailed information about OpenCart , you can directly go to its official web site.

You might also like:

Sidebar



back to top