OpenCart is a popular open-source eCommerce store solution designed to offer excellent functionality, simplicity, and management of online stores from a single back-end dashboard. With OpenCart, you can quickly build a complete online shopping store and customize it with free extensions for your needs.
In this article, you will install OpenCart on a Ubuntu 20.04 server running on a LEMP (Nginx, MySQL, PHP) stack. But first, your installation needs to meet a few requirements.
Deploy a Ubuntu 20.04 LEMP Server from the Vultr Marketplace Apps
SSH to the server and log in as root.
Optionally, you can configure a domain name to point to your server.
Login to MySQL.
$ mysql -u root
Create a new database for OpenCart.
mysql> create database opencart;
Create a new database user and a strong password.
mysql> create user 'adminâ@âlocalhost' IDENTIFIED BY 'YOUR_STRONG_PASSWORD';
Grant the user full rights to the OpenCart database.
mysql> GRANT ALL PRIVILEGES ON opencart.* TO 'adminâ@âlocalhost';
Refresh rights and Exit the MySQL console.
mysql>FLUSH PRIVILEGES; mysql>EXIT
Download the latest stable version of OpenCart from its Github repository. In this article, we install version 18.104.22.168, consider checking for the latest version.
$ wget https://github.com/opencart/opencart/releases/download/22.214.171.124/opencart-126.96.36.199.zip
Extract files from the OpenCart Zip archive.
$ unzip opencart-188.8.131.52.zip -d opencart
Move the extracted files to your web server root directory; by default, Nginx uses
$ sudo mv opencart/upload/* /usr/share/nginx/html
Change ownership rights to the user and group nginx identified by
$ sudo chown -R www-data:www-data /usr/share/nginx/html
Set up OpenCart by renaming the template configuration files to the production names.
$ cd /usr/share/nginx/html $ sudo mv config-dist.php config.php $ sudo mv admin/config-dist.php admin/config.php
Allow HTTP and HTTPS traffic on your server.
$ sudo ufw allow 80 $ sudo ufw allow 8080 $ sudo ufw allow http $ sudo ufw allow https
Since most modern browsers and OpenCart use HTTPS, you must install a free SSL/TLS certificate to avoid certificate errors. To do so, install certbot and its Nginx plugin.
$ sudo apt install certbot python3-certbot-nginx
Request a new SSL certificate for your domain.
$ certbot ânginx -d example.com www.example.com
Enter your email address and agree to the terms of service, then configure your HTTPS settings, and once done, a valid certificate will be installed on your server.
IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/example.com/privkey.pem
Visit your server's public IP Address or the associated domain name through a web browser to start the OpenCart installation process.
Click Continue to agree to the product terms and conditions on the main welcome screen.
OpenCart will attempt to check if your server meets all requirements; once passed, click Continue.
Input the database name, username, and password created on Step 1 of this article.
Click continue to finish the installation process and access your main OpenCart administrator dashboard to make further configurations.
If you have installed OpenCart on a production server, it is recommended to secure your server by performing the following instructions.
Delete the installation file.
$ sudo rm -r /usr/share/nginx/html/install
Change File Permissions for the following files to 644.
$ sudo chmod 644 /usr/share/nginx/html/config.php $ sudo chmod 644 /usr/share/nginx/html/index.php $ sudo chmod 644 /usr/share/nginx/html/admin/config.php $ sudo chmod 644 /usr/share/nginx/html/admin/index.php $ sudo chmod 644 /usr/share/nginx/html/system/startup.php
Secure the Administrator directory/Login URL by renaming it.
$ sudo mv /usr/share/nginx/html/admin privatemin
Your Login URL will be changed from
privatemin with the above command. You can change it to your preferred secret keyword, and you will be able to access your OpenCart server dashboard through it.
Congratulations, you have installed OpenCart on your Ubuntu 20.04 server. You can create and configure your new store by visiting your server IP or associated domain name.