1. Initial Command Overview
The following commands install and start Firewalld and MariaDB, update the firewall to allow traffic on port 3306, and launch the MySQL client:Although the instructions include manual editing of
/etc/my.cnf using vi, you can automate configuration changes with tools like sed for a fully automated deployment.2. Developing the Deployment Script
Create the deployment script locally using your favorite IDE (e.g., PyCharm) and test it in your lab environment. Name the script file, for example,deploy_ECommerce_Application.sh. Start by copying the essential commands from your Git repository before gradually improving and testing the script.
An initial version might look like this:
-y option) and highlights any permission or manual input issues.
3. Database Configuration
3.1. Configuring the Database
Create a SQL script to setup the database by creating a database, user, and assigning privileges:For automated configuration, consider replacing manual edits with command-line utilities such as
sed to modify files like /etc/my.cnf programmatically.3.2. Loading Inventory Data
Load sample inventory data by creating a SQL script that creates a table and populates it with product details:sudo.
4. Web Server Configuration
Install and configure Apache, PHP, and Git. Modify the server configuration to useindex.php instead of index.html and clone the application repository.
5. Enhancing the Script with Checks and User-Friendly Messages
For a production-grade script, it is ideal to include functions that provide colored status messages, verify service activity, and confirm that firewall rules and web content are as expected. Below is an example of an enhanced deployment script:Explanation
-
Functions for User-Friendly Output:
The functionsprint_color,check_service_status, andcheck_firewalld_portoffer colored output and validate that necessary services and firewall rules are active. -
Database Setup:
SQL scripts (configure-db.sqlanddb-load-script.sql) configure the database and load inventory data. Executing these withsudo mysqlensures proper permission handling. -
Web Server Setup:
Apache is installed and configured to useindex.phpviased, and the application repository is cloned into/var/www/html. The script updates the IP address inindex.phpwithlocalhost, standardizing the environment. -
Final Testing:
The script usescurlto fetch the web content and verifies the presence of key items such as “Laptop”, “Drone”, etc.