• 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:2. Deploying and Configuring the Database
Installing MariaDB Server
Install the MariaDB server package using the following command:/etc/my.cnf. Below is an example configuration; unless you need to change the default port or other settings, the provided configuration remains suitable:
Adding the Firewall Rule for MariaDB
Open port 3306 (the default MySQL port) by executing: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. :::-
Create the Database:
-
Verify the Database:
If a typo occurs, such as
show database;, correct it using: -
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.
-
Create the SQL Script File:
Run the command below to create the file and paste the content:
-
Sample Contents of db-load-script.sql:
-
Load the Data:
Execute the script with:
-
Verification:
Log in to the MariaDB monitor and switch to the ecomdb database to confirm the data was loaded:
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: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:Downloading the Application Code
Ensure Git is installed, then clone the ecommerce repository into the web server’s document root: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 themysqli_connect call.
Change the connection parameters from:
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:
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.