LiteCart is a free and open source online catalog and shopping cart platform writtent in PHP language. It is very popular due to it’s simplicity, lightweight and easy to use web interface.
The framework is constructed to be lightweight and easy for developers to modify and build upon. LiteCart relies on the latest HyperText standard HTML 5, CSS 3, jQuery framework and PHP.
Here, we will learn how to install and configure LiteCart on your Ubuntu 15.04 server with Nginx, PHP-FPM and MySQL.
Requirements
- A server running Ubuntu Ubuntu 16.04 server.
- A non root user with sudo privileges setup on your server.
Update the System
Before installing any packages, it is recommended to update your system with the latest stable version. You can do this with the following command:
sudo apt-get update -y
sudo apt-get upgrade -y
Once your system is up to date, you can proceed to install Nginx web server.
Install Nginx
First, you will need to install Nginx web server on your server. You can install it with the following command:
sudo apt-get install nginx -y
Once Nginx is installed, start Nginx service and enable it to start on boot time with the following command:
sudo systemctl start nginx
sudo systemctl enable nginx
Once you are done, you can proceed to the next step.
Install PHP
Next, you will need to install PHP, PHP-FPM and other PHP libraries on your server.
You can install all of them with the following command:
sudo apt-get install php5 php5-fpm php5-mysql php5-curl php5-mcrypt php5-gd -y
Once all of them are installed, you can proceed to install MySQL server.
Install and Configure MySQL
LiteCart store it’s data in MySQL. So you will need to install MySQL on your server. You can install it by running the following command:
sudo apt-get install mysql-server mysql-client -y
Once MySQL is installed, start mysql service and enable it to start on boot time with the following command:
sudo systemctl start mysql
sudo systemctl enable mysql
By default, MySQL installation is not secured, so you will need to secure it first. Next, you will also need to secure your MySQL installation. You can do this by running mysql_secure_installation script:
sudo mysql_secure_installation
Answer all the questions as shown below:
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 MySQL is secured, log in to the MySQL shell and create a database for LiteCart:
mysql -u root -p
Enter your root password when prompt, then create a database for LiteCart. It is recommended to set secure password:
mysql>CREATE DATABASE litecartdb;
Query OK, 1 row affected (0.00 sec)
Next, create a username and password for LiteCart with the following command:
mysql>CREATE USER 'litecartuser'@'localhost' IDENTIFIED BY 'password';
Query OK, 1 row affected (0.00 sec)
Next, grant privileges to the LiteCart database with the following command:
mysql>GRANT ALL PRIVILEGES ON litecartdb.* TO 'litecartuser'@'localhost';
Query OK, 1 row affected (0.00 sec)
Next, you will need to run the FLUSH PRIVILEGES command so that the privileges table will be reloaded by MySQL and we can use new credential:
mysql>FLUSH PRIVILEGES;
Query OK, 1 row affected (0.00 sec)
Next, exit from the MySQL console with the following command:
mysql>\q
Once you are done, you can proceed to the next step.
Install LiteCart
First, you will need to download the latest version of the LiteCart from their official website. Once the download is completed.
unzip the downloaded file with the following command:
sudo mkdir /var/www/html/litecart
sudo unzip litecart-2.0.zip -d /var/www/html/litecart/
Next, give proper permission to the litecart directory:
sudo chown -R www-data:www-data /var/www/html/litecart
Once you are done, you can proceed to the next step.
Configure Nginx for LiteCart
Next, you will need to create a Nginx virtual host file for LiteCart. You can do this by creating litecart.conf file inside /etc/nginx/sites-available directory:
sudo nano /etc/nginx/sites-available/litecart.conf
Add the folowing lines:
server {
listen 80 ;
root /var/www/html/litecart/public_html;
index index.php index.html index.htm;
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
server_name yourdomain.com ;
access_log /var/log/nginx/litecart-access.log;
error_log /var/log/nginx/litecart-error.log;
location / {
# try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Next, enable your virtual host with the following command:
sudo a2ensite litecart.conf
Finally, restart Nginx for the changes to take effect:
sudo systemctl restart nginx
Once you are done, you can proceed to the next step.
Access LiteCart Web Interface
Before accessing the LiteCart Web Interface, you will need to allow HTTP service through UFW firewall.
By default UFW is disabled on your system, so you need to enable it first.
You can enable it with the following command:
sudo ufw enable
Once UFW firewall is enabled, you can allow HTTP service by running the following command:
sudo ufw allow http
You can now check the status of UFW firewall by running the following command:
sudo ufw status
Next, Open your web browser and type the URL http://yourdomain.com, you should see the following page:
HP_NO_IMG/data/uploads/users/f36d03b4-5bf0-4986-8e72-2e14d73d9b4d/1504925541.png” alt=”” />
Make sure all the system requirements are fulfilled, then click on the Next
button you should see the following page:
HP_NO_IMG/data/uploads/users/f36d03b4-5bf0-4986-8e72-2e14d73d9b4d/295591722.png” alt=”” />
Here, provide all the information like, database name, database username, password, store name, admin username and password, then click on the Next
button, you should see the following installation completed message:
HP_NO_IMG/data/uploads/users/f36d03b4-5bf0-4986-8e72-2e14d73d9b4d/342247820.png” alt=”” />
Finally, click on administratio are
button, you should see the LiteCart login page in following image:
HP_NO_IMG/data/uploads/users/f36d03b4-5bf0-4986-8e72-2e14d73d9b4d/963458963.png” alt=”” />
Here, provide your admin credential and click on Login
button, you should see the LiteCart Default dashboard in below image:
HP_NO_IMG/data/uploads/users/f36d03b4-5bf0-4986-8e72-2e14d73d9b4d/1591482462.png” alt=”” />
Congratulations! You have successfully installed LiteCart on your Ubuntu 16.04 server.