How to Install LiteCart e-commerce platform on Ubuntu 20.04 LTS
This tutorial exists for these OS versions
- Ubuntu 20.04 (Focal Fossa)
- Ubuntu 18.04 (Bionic Beaver)
On this page
LiteCart is an open-source and lightweight e-commerce platform in written in PHP, HTML 5, and CSS 3. It is simple, easy to use, and has an elegant and simple admin panel. LiteCart is faster than 99% of all websites in the world. It comes with a rich set of features including, Innovative, High performance, Plug and play add-ons, SEO friendly, One step checkout, Multiple charset support and many more.
In this tutorial, we will show you how to install LiteCart shopping cart platform on Ubuntu 20.04.
Prerequisites
- A server running Ubuntu 20.04.
- A valid domain name pointed with your server.
- A root password is configured on your server.
Getting Started
Before starting, it is recommended to update your system with the latest stable version. You can update it with the following command:
apt-get update -y
apt-get upgrade -y
Once your system is up-to-date, restart it to apply the changes:
Install LAMP Server
First, you will need to install the Apache webserver, MariaDB server, PHP and other required PHP libraries in your system. You can install all of them with the following command:
apt-get install apache2 mariadb-server php7.4 libapache2-mod-php7.4 php7.4-common php7.4-mbstring php7.4-xmlrpc php7.4-soap php7.4-gd php7.4-xml php7.4-intl php7.4-mysql php7.4-cli php7.4-zip php7.4-curl php7.4-soap unzip -y
Once all the packages are installed, edit the php.ini file and tweak some desired settings:
nano /etc/php/7.4/apache2/php.ini
Change the following lines:
memory_limit = 256M upload_max_filesize = 150M max_execution_time = 360 date.timezone = Asia/Kolkata
Save and close the file when you are finished. Then, restart the Apache service to apply the changes:
systemctl restart apache2
Configure MariaDB Database
First, you will need to secure the MariaDB and set the MariaDB root password. You can do it with the following command:
mysql_secure_installation
Answer all the questions as shown below:
Enter current password for root (enter for none): Set root password? [Y/n]: N Remove anonymous users? [Y/n]: Y Disallow root login remotely? [Y/n]: Y Remove test database and access to it? [Y/n]: Y Reload privilege tables now? [Y/n]: Y
Once you are finished, login to the MariaDB shell with the following command:
mysql -u root -p
Provide your root password when prompt then create a database and user for LiteCart with the following command:
MariaDB [(none)]> CREATE DATABASE litecartdb;
MariaDB [(none)]> CREATE USER 'litecart'@'localhost' IDENTIFIED BY 'password';
Next, grant all the privileges to the litecartdb with the following command:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON litecartdb.* TO 'litecart'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
Next, flush the privileges and exit from the MariaDB shell with the following command:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Once your database is configured, you can proceed to the next step.
Download LiteCart
At the time of writing this tutorial, the latest version of LiteCart is 2.2.3. You can download it from its official website. After downloading, extract the downlaoded file to the Apache web root directory with the following command:
mkdir /var/www/html/litecart
unzip litecart-2.2.3.1.zip -d /var/www/html/litecart
Next, change the ownership of the litecart directory to www-data and give proper permissions with the following command:
chown -R www-data:www-data /var/www/html/litecart/
chmod -R 755 /var/www/html/litecart/
Once you are finished, you can proceed to the next step.
Configure Apache for LiteCart
First, create a new Apache virtual host configuration file with the following command:
nano /etc/apache2/sites-available/litecart.conf
Add the following lines:
<VirtualHost *:80> ServerAdmin [email protected] ServerName litecart.linuxbuz.com DocumentRoot /var/www/html/litecart/public_html/ <Directory /var/www/html/litecart/> AllowOverride All allow from all </Directory> ErrorLog /var/log/apache2/litecart_error.log CustomLog /var/log/apache2/litecart_access.log combined </VirtualHost>
Save and close the file when you are finished. Then, enable the LiteCart site, rewrite and headers module with the following command:
a2ensite litecart.conf
a2enmod rewrite
a2enmod headers
Finally, restart the Apache service to apply the changes:
systemctl restart apache2
At this point, your Apache web server is configured to serve LiteCart.
Secure LiteCart with Let's Encrypt SSL
It is recommended to secure the LiteCart website with Let's Encrypt free SSL. To do so, install the Certbot Let's Encrypt Client with the following command:
apt-get install certbot python3-certbot-apache -y
Once the Certbot is installed, run the following command to install the Let's Encrypt SSL for your domain:
certbot --apache -d litecart.linuxbuz.com
You will need to provide your email address and accept the term of service as shown below:
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator apache, Installer apache Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): [email protected] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v02.api.letsencrypt.org/directory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (A)gree/(C)ancel: A - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y Obtaining a new certificate Performing the following challenges: http-01 challenge for litecart.linuxbuz.com Waiting for verification... Cleaning up challenges Created an SSL vhost at /etc/apache2/sites-available/litecart-le-ssl.conf Enabled Apache socache_shmcb module Enabled Apache ssl module Deploying Certificate to VirtualHost /etc/apache2/sites-available/litecart-le-ssl.conf Enabling available site: /etc/apache2/sites-available/litecart-le-ssl.conf
Next, you will need to choose whether you want to redirect HTTP traffic to HTTPS or not as shown below:
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Select option 2 and hit Enter to finish the installation as shown below:
Redirecting vhost in /etc/apache2/sites-enabled/litecart.conf to ssl vhost in /etc/apache2/sites-available/litecart-le-ssl.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://litecart.linuxbuz.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=litecart.linuxbuz.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/litecart.linuxbuz.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/litecart.linuxbuz.com/privkey.pem Your cert will expire on 2020-09-12. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew" - Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
At this point, your LiteCart website is secured with Let's Encrypt SSL. You can now proceed to the next step.
Access LiteCart
Now, open your web browser and type the URL https://litecart.linuxbuz.com. You will be redirected to the following page:
Provide your installation path, database details, store information, admin username, password and click on the Install Now button. Once the installation has been completed successfully, you should see the following page:
Next, remove the installation directory using the following command:
rm -rf /var/www/html/litecart/public_html/install/
Click on the administration area button. You will be redirected to the LiteCart login page as shown below:
Provide your admin username, password and click on the Login button. You should see the LiteCart dashboard in the following page:
Conclusion
In the above guide, you learned how to install and secure the LiteCart shopping cart on Ubuntu 20.04. You also learned how to secure it with Let's Encrypt free SSL. I hope you can now host your own shopping cart application with LiteCart.