OpenCart is a free and open-source e-commerce platform built with PHP. Its features and lightweight user-friendly interface make it powerful and more popular. You can easily manage product inventory, orders, affiliates, discounts, product reviews, payment gateways. In addition, it comes with awesome themes and plugins that make your opencart store more attractive, functional, secure and powerful. In this article, I am going to share how to install Opencart on Ubuntu 20.04 easily. So, let’s get started.
Prerequisites
- Ubuntu 20.04 server
- SSH access to the server
- LAMP stack installed. If not installed, you can install it by following this tutorial.
- Domain mapped with server IP and secured with SSL.(Optional)
How to Install Opencart on Ubuntu 20.04
Opencart can be installed in multiple ways. Some of the hosting services such as AWS, Digital Ocean, Google Cloud offer one click setup. If you are using cPanel, you can install Opencart via Softaculous.
In this article, I am sharing complete manual installation steps which will work on almost every Linux based Ubuntu server.
Step 1: Update Software Packages
First SSH into the Ubuntu server and update ubuntu software packages.
sudo apt update
sudo apt upgrade
Step 2: Install LAMP on the Ubuntu Server
If you haven’t configured the LAMP stack yet, follow this article for detailed instructions. However, I am sharing quick installation steps here.
sudo apt install apache2
sudo apt install mysql-server
Opencart latest version needs the PHP 8 version, you can download PHP 8 by following this article. To install PHP 8, run the following command.
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.0 libapache2-mod-php8.0 php8.0-zip php8.0-curl
Restart apache server by following command.
sudo systemctl restart apache2
If you want to enable apache with PHP-FPM, run below command.
sudo apt install php8.0-fpm libapache2-mod-fcgid
By default PHP-FPM not enabled, to make it enable run following command.
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.0-fpm
Step 3: Create MySQL database
Create a database for Opencart installation, login to MySQL console and create a database.
mysql -u root -p
After login to the MySQL dashboard, create a database.
mysql> CREATE DATABASE opencartDB;
mysql> exit;
Step 4: Download Opencart
Now, download the latest Opencart version using wget
under /tmp directory and unzip the downloaded file.
cd /tmp
wget https://github.com/opencart/opencart/archive/refs/heads/master.zip
Once the Opencart downloaded. Unzip the file using unzip.
unzip master.zip
sudo mv /tmp/opencar-master/. /var/www/html
Step 5: Configure Document root
Copy the configuration files by cp command.
sudo cp /var/www/html/{config-dist.php,config.php}
sudo cp /var/www/html/admin/{config-dist.php,config.php}
Step 6: Change File Permissions of the Document root
Modify files and directory permission of the document root by following commands.
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
Step 7: Install Opencart through the Browser
Now, hit the domain name or server IP address on the browser address to continue installation.
Click on continue to check the server configuration and make sure all the required PHP extensions are installed on the server and then click continue install opencart on Ubuntu 20.04
Now filled up database details for the installation, and also created an administrator account with desired username and password.
After filling up all the details, click next to complete the installation. Once the installation is completed, you will be asked to delete the installation directory.
Delete installation directory from the document root and you are done. Now you can access the website on the browser.
yourdomainname.com or server_ip
Your website admin access link.
yourdomainname.com/admin or server_ip/admin
Conclusion
In this article, you have learned how to install opencart on Ubuntu 20.04. If you have any doubts feel free to contact me, I will definitely try to help you. Also, you can join our elite Facebook group to get direct help from me. If you like this tutorial, please share this article on your social media handle.
1 Comment
This guide is not accurate. where’s the step that you create a folder named opencart inside /html/ and moving all files inside opencart-master to that folder? and how do you expect that cp command to work if there’s no such file?
Follow these,
$ sudo mkdir /var/www/html/opencart
$ sudo mv opencart-master/* /var/www/html/opencart
$ sudo cp /var/www/html/opencart/upload/{config-dist.php,config.php}
$ sudo cp /var/www/html/opencart/upload/admin/{config-dist.php,config.php}
$ sudo chown -R www-data:www-data /var/www/html/opencart
$ sudo chmod -R 755 /var/www/html/opencart