From f6762b7f0d97b2a3715c27d02eb3645508e276e3 Mon Sep 17 00:00:00 2001 From: fadmin Date: Tue, 9 Jun 2026 03:43:53 -0400 Subject: [PATCH] uninstall-LAMP-phpMyAdmin-PHP82.sh --- uninstall-LAMP-phpMyAdmin-PHP82.sh | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 uninstall-LAMP-phpMyAdmin-PHP82.sh diff --git a/uninstall-LAMP-phpMyAdmin-PHP82.sh b/uninstall-LAMP-phpMyAdmin-PHP82.sh new file mode 100644 index 0000000..c57ad58 --- /dev/null +++ b/uninstall-LAMP-phpMyAdmin-PHP82.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Check for root privileges +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root (use sudo)" + exit 1 +fi + +echo "--- Starting LAMP Stack Uninstallation ---" + +# 1. Stop and Disable Services +echo "Stopping Apache and MariaDB..." +sudo systemctl stop httpd mariadb 2>/dev/null +sudo systemctl disable httpd mariadb 2>/dev/null + +# 2. Remove Packages +echo "Removing Apache, MariaDB, PHP 8.2, and phpMyAdmin..." +sudo dnf remove -y httpd mariadb-server php php-* phpmyadmin remi-release + +# 3. Clean up PHP Module Streams +echo "Resetting PHP module streams..." +sudo dnf module reset php -y + +# 4. Delete Configuration Files and Data +# WARNING: This deletes your databases and website files! +read -p "Do you want to delete all Web files and Databases? (y/n): " CONFIRM +if [[ $CONFIRM == [yY] ]]; then + echo "Deleting /var/www/ and /var/lib/mysql/..." + sudo rm -rf /var/www/* + sudo rm -rf /var/lib/mysql + sudo rm -rf /etc/httpd + sudo rm -rf /etc/php.d + sudo rm -rf /etc/phpmyadmin + echo "Files deleted." +else + echo "Skipping file deletion. Configs and Data remain in /etc/ and /var/." +fi + +# 5. Reset Firewall Rules (Optional) +echo "Removing HTTP/HTTPS firewall rules..." +sudo firewall-cmd --permanent --remove-service={http,https} +sudo firewall-cmd --reload + +# 6. Clean DNF Cache +sudo dnf clean all + +echo "------------------------------------------------" +echo "Uninstallation Complete!" +echo "The LAMP stack and PHP 8.2 have been removed." +echo "------------------------------------------------"