1. Deploying Prerequisites
First, install and configure the firewall (firewalld) so that it automatically starts on system boot. This ensures that your system rules are applied correctly, aiding in troubleshooting any future issues.Install and Start Firewalld
Execute the following commands to install firewalld, start the service, enable it to run on reboot, and confirm its status:Ensure that all expected firewall rules are active, confirming firewalld is running as intended.
2. Installing and Configuring the Database
The application uses MariaDB as its database server. The steps below demonstrate how to install, configure, and secure MariaDB.Installing MariaDB
Install MariaDB using the package manager and review the configuration file:/etc/my.cnf) appears as follows:
If you need to change settings like the MySQL port or adjust other configurations, update this file as required. For this demo, default settings are maintained.
Adding a Firewall Rule for MariaDB
Since MariaDB uses the default MySQL port (3306), add this port to firewalld permanently and then reload the service:Configuring the Database
Follow these steps to configure MariaDB for the e-commerce application:- Create the database.
- Create a new user with appropriate privileges.
- Load sample inventory data.
Loading Inventory Data
To populate theecomdb database with sample data, create a SQL script (for example, named db-load-script.sql). You can either copy the script from the GitHub repository’s assets or create it manually:
3. Deploying and Configuring the Web Application
Now that your database is set up and configured, let’s deploy the web application using Apache, PHP, and the required MySQL driver.Installing Required Packages
First, install Apache (httpd), PHP, and the PHP MySQL driver. Then add a firewall rule for HTTP (port 80):Configuring Apache
Modify Apache’s configuration to prioritizeindex.php over index.html. Use the following command to update the configuration:
Downloading the Application Code
Ensure Git is installed on your machine:index.php file to use localhost:
Verifying the Application’s Database Connection
Review theindex.php file to ensure the MySQL credentials and host settings are correct. The relevant PHP section should resemble:
By following these steps, you have successfully deployed and configured the KodeKloud e-commerce application on a CentOS machine. Both the database and web server are now running and properly connected.