Skip to main content
In this article, we demonstrate how to deploy the KodeKloud ecommerce application manually on a CentOS machine—without using automation tools like Ansible. You can use any available CentOS machine or quickly access a CentOS playground online. The application’s source code is hosted on GitHub in the learning-app-ecommerce repository maintained by the KodeKloud organization. The repository includes all necessary deployment files along with a detailed README file divided into three sections: • Deploying prerequisites
• Deploying and configuring the database
• Deploying and configuring the web server
Follow the steps below sequentially to complete the manual deployment.

1. Deploying Prerequisites

Installing and Configuring firewalld

Begin by installing firewalld, then start and enable the service to run on system boot:
If you need to troubleshoot, verify the service status with:
When adding firewall rules later in the process, you can list all active rules with:
A sample troubleshooting session might resemble:

2. Deploying and Configuring the Database

Installing MariaDB Server

Install the MariaDB server package using the following command:
After installation, you can review or modify default settings in the configuration file /etc/my.cnf. Below is an example configuration; unless you need to change the default port or other settings, the provided configuration remains suitable:
Start and enable MariaDB:
A sample session to verify these steps:

Adding the Firewall Rule for MariaDB

Open port 3306 (the default MySQL port) by executing:
Confirm that the new rule is active:

Configuring the Database

Access the MariaDB monitor to create the database, add a new user, and grant the necessary privileges. :::note Database Setup In this example, we create a database named ecomdb and a user ecomuser with the password ecompassword. :::
  1. Create the Database:
  2. Verify the Database: If a typo occurs, such as show database;, correct it using:
  3. Create a Database User and Grant Privileges:

Loading Inventory Data

The GitHub repository includes a SQL script (DB-load-script.sql in the assets directory) that creates a products table with sample data.
  1. Create the SQL Script File: Run the command below to create the file and paste the content:
  2. Sample Contents of db-load-script.sql:
  3. Load the Data: Execute the script with:
  4. Verification: Log in to the MariaDB monitor and switch to the ecomdb database to confirm the data was loaded:
At this point, the database is configured and pre-populated with sample data.

3. Deploying and Configuring the Web Application

Installing HTTPD, PHP, and MySQL Extensions

Install the required web server packages along with PHP and its MySQL extension:
Add the firewall rule for HTTP (port 80) and reload firewalld:

Configuring HTTPD

To configure Apache, open the configuration file and modify the DirectoryIndex if needed. For example, change the default file to index.php by editing the file:
Locate and adjust the DirectoryIndex section from:
to:
After saving the changes, restart HTTPD:

Downloading the Application Code

Ensure Git is installed, then clone the ecommerce repository into the web server’s document root:
Verify the files were cloned successfully:

Updating Database Connection Settings

By default, the application’s index.php file is configured to connect to an IP address (e.g., 172.20.1.101). Since this is an all-in-one setup, update the database connection details to use localhost. Open index.php and locate the mysqli_connect call. Change the connection parameters from:
to:
Save the file and refresh your web page. You can also test the server response with:
If the connection is correctly configured, you will see a list of products fetched from the database.

Troubleshooting Default Page Issues

If an index.html file exists alongside index.php, Apache might serve index.html by default. Ensure that the DirectoryIndex configuration in /etc/httpd/conf/httpd.conf prioritizes index.php. If necessary, remove or rename the default index.html. For example, to create a temporary index file:
After adjusting the DirectoryIndex value, restart HTTPD:
Now, accessing your site should display the ecommerce application (i.e., index.php) rather than the sample index.html.

Conclusion

Following these steps, you have successfully deployed the KodeKloud ecommerce application manually on a CentOS machine. The process included: • Installing and configuring firewalld and MariaDB
• Setting up the database by creating the database, adding a user, and loading sample data
• Installing and configuring HTTPD, PHP, and cloning the application code
• Updating the database connection settings in index.php
This demonstration highlights how all components work together in a manual deployment scenario. Enjoy exploring the KodeKloud ecommerce application and refer to the KodeKloud GitHub repository for further information and updates.

Watch Video

Practice Lab