APACHE + Opening ports installation
Choose your system:
Variants:
Install/Uninstall script (Docker /
Warning: Undefined array key "
Deprecated: htmlspecialchars(): Passing null to parameter " in /var/www/scripts/PHP_HTML/maininstall.php on line 49
Warning: Trying to access array offset on null in /var/www/scripts/PHP_HTML/maininstall.php on line 49
Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/scripts/PHP_HTML/maininstall.php on line 49
)
#!/bin/bash
set -e
# ========== COLORS ==========
NC='\033[0m'
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
BOLD='\033[1m'
# ========== SPINNER ==========
spinner_pid=""
start_spinner() {
local msg="$1"
echo -ne "${BLUE}[INFO] ℹ️${NC} ${msg}... "
trap stop_spinner INT
(
local spin='-\|/'
while true; do
for i in $(seq 0 $(( ${#spin} - 1 )) ); do
echo -ne "\b${spin:$i:1}"
sleep 0.1
done
done
) &
spinner_pid=$!
disown
}
stop_spinner() {
if [[ -n "$spinner_pid" ]]; then
kill "$spinner_pid" &>/dev/null || true
wait "$spinner_pid" 2>/dev/null || true
spinner_pid=""
fi
echo -e "\b${GREEN}[OK] ✓${NC}"
trap - INT
}
run_step() {
start_spinner "$1"
shift
"$@" &>/dev/null
stop_spinner
}
run_multistep() {
start_spinner "$1"
shift
{
"$@"
} &>/dev/null
stop_spinner
}
# ========== DETECT DISTRO ==========
DISTRO=""
if [[ -f /etc/os-release ]]; then
. /etc/os-release
DISTRO=$(echo "$ID" | tr '[:upper:]' '[:lower:]')
fi
[[ "$DISTRO" == "rhel" ]] && DISTRO="centos"
echo -e "\n${BOLD}${YELLOW}=== Docker Installer / Uninstaller ===${NC}"
echo -e "${BLUE}[INFO] Detected distribution: ${BOLD}${DISTRO}${NC}"
# ========== ASK FOR ACTION ==========
echo "1) Install Docker"
echo "2) Uninstall Docker"
read -rp "Choose an option [1-2]: " ACTION
if [[ "$ACTION" == "1" ]]; then
echo -e "\n${BOLD}${YELLOW}=== Installing Docker ===${NC}"
case "$DISTRO" in
debian|ubuntu)
run_multistep "Updating packages" bash -c "sudo apt update -y"
run_step "Installing prerequisites" sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release
run_step "Adding Docker GPG key" curl -fsSL https://download.docker.com/linux/$(. /etc/os-release && echo "$ID")/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \
https://download.docker.com/linux/$(. /etc/os-release && echo "$ID") \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
run_multistep "Updating package list (Docker repo)" bash -c "sudo apt update -y"
run_step "Installing Docker Engine" sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
;;
centos|almalinux|rocky|oracle)
run_multistep "Installing prerequisites" bash -c "sudo dnf install -y dnf-plugins-core"
run_step "Adding Docker repo" sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
run_step "Installing Docker Engine" sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
;;
*)
echo -e "${RED}[ERROR] Unsupported distribution: $DISTRO${NC}"
exit 1
;;
esac
run_step "Starting Docker service" sudo systemctl start docker
run_step "Enabling Docker to start on boot" sudo systemctl enable docker
echo -e "\n${GREEN}[DONE] ✅${NC} Docker has been installed."
echo -e "${BOLD}Check Docker status:${NC} sudo systemctl status docker"
echo -e "${BOLD}Test Docker:${NC} sudo docker run hello-world"
elif [[ "$ACTION" == "2" ]]; then
echo -e "\n${BOLD}${YELLOW}=== Uninstalling Docker ===${NC}"
run_step "Stopping Docker service" sudo systemctl stop docker || true
case "$DISTRO" in
debian|ubuntu)
run_multistep "Removing Docker packages" bash -c "sudo apt remove --purge -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
run_multistep "Cleaning system" bash -c "sudo apt autoremove -y && sudo apt clean"
;;
centos|almalinux|rocky|oracle)
run_multistep "Removing Docker packages" bash -c "sudo dnf remove -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
run_multistep "Cleaning system" bash -c "sudo dnf autoremove -y && sudo dnf clean all"
;;
*)
echo -e "${RED}[ERROR] Unsupported distribution: $DISTRO${NC}"
exit 1
;;
esac
run_multistep "Removing Docker data" sudo rm -rf /var/lib/docker /var/lib/containerd
echo -e "\n${GREEN}[DONE] ✅${NC} Docker has been completely uninstalled."
else
echo -e "${RED}[ERROR] Invalid option.${NC}"
exit 1
fi
Use the following command to auto-download and run:
Warning: Undefined array key "
Deprecated: htmlspecialchars(): Passing null to parameter " in /var/www/scripts/PHP_HTML/autoscripts.php on line 87
Warning: Trying to access array offset on null in /var/www/scripts/PHP_HTML/autoscripts.php on line 87
curl -fsSL -o script.sh "https://krotek.serveblog.net/how-to-install/WEB-SERVER/APACHE/scripts.php?variant=docker&type=script&system=%3Cbr+%2F%3E%3Cb%3EDeprecated%3C%2Fb%3E%3A++htmlspecialchars%28%29%3A+Passing+null+to+parameter+" && chmod +x script.sh && sudo ./script.sh