Files
LAMP-Server-Fedora/uninstall-LAMP-phpMyAdmin-PHP82.sh

51 lines
1.5 KiB
Bash

#!/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 "------------------------------------------------"