This guide explains how to deploy the KodeKloud ECommerce Application on a CentOS machine, covering prerequisites, database configuration, and web server setup.
In this guide, we will walk you through deploying the KodeKloud ECommerce Application on a CentOS machine. The application code is hosted on GitHub in the “learning-app-ecommerce” repository at KodeKloud Hub. The repository contains all the required files plus a README that explains how to deploy prerequisites, configure the database, and set up the web server.Below is a detailed, step‑by‑step walkthrough.
To verify that MariaDB is running correctly, check its status:
Copy
Ask AI
sudo service mariadb status
Sample output:
Copy
Ask AI
[root@eb29eab4d499 ~]# sudo service mariadb statusRedirecting to /bin/systemctl status mariadb.service● mariadb.service - MariaDB database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2019-10-11 10:55:08 UTC; 13s ago Main PID: 1842 (mysqld_safe) CGroup: /system.slice/mariadb.service └─1842 /bin/sh /usr/bin/mysqld_safe --basedir=/usr └─2004 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --...
The MariaDB configuration file (/etc/my.cnf) may have settings similar to:
Copy
Ask AI
[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mariadb/mariadb.logpid-file=/var/run/mariadb/mariadb.pid
Leave these settings as default unless you require any custom changes, such as modifying the port.
At the MariaDB monitor, execute the following SQL commands to create the database, user, and grant necessary privileges. In this example, the database is “ecomdb”, the user is “ecomuser”, and the password is “ecompassword”:
Copy
Ask AI
CREATE DATABASE ecomdb;SHOW DATABASES;CREATE USER 'ecomuser'@'localhost' IDENTIFIED BY 'ecompassword';GRANT ALL PRIVILEGES ON *.* TO 'ecomuser'@'localhost';FLUSH PRIVILEGES;
Successful execution of these commands should display no errors, and SHOW DATABASES; will list “ecomdb”.
The repository provides a SQL script (usually in the assets directory named db-load-script.sql) that creates a “products” table and inserts sample data.
Create the SQL script file:
Copy
Ask AI
cat > db-load-script.sql
Open the file in your favorite text editor and insert the following:
Before making adjustments, verify that the application is accessible by using a web browser or curl:
Copy
Ask AI
curl http://localhost
At this stage, you might see a default page that does not display the configured e-commerce application. This may be due to an old database connection configuration.
Open the index.php file from the cloned repository and update the database connection details. Replace any external IP address (e.g., 172.20.1.101) with localhost and ensure the username, password, and database name match your configuration:
If an index.html file exists in the document root of your web server, Apache might serve that file by default over index.php. To ensure that Apache serves the e-commerce application:
Either remove/rename the index.html file, or
Update the DirectoryIndex directive in /etc/httpd/conf/httpd.conf as shown below:
Copy
Ask AI
DirectoryIndex index.php
Restart Apache to apply the changes:
Copy
Ask AI
sudo service httpd restart
Then, confirm by visiting:
Copy
Ask AI
curl http://localhost
Your e-commerce application should now display the products loaded from the database.Thank you for following this guide on deploying the KodeKloud ECommerce Application. With both the web server and the application correctly configured along with its database, your e-commerce site should now be fully operational.For further reading on web server deployment and database configuration concepts, consider checking out these resources: