############################################################
檢查 Ubuntu 版本
確保 Ubuntu 系統是最新版本,執行以下命令:
lsb_release -a
sudo apt update && sudo apt upgrade -y
安裝必要工具
確保系統上有 wget
和 curl
等常用工具:
sudo apt install wget curl unzip -y
安裝 Apache2:
sudo apt install apache2 -y
啟用和檢查 Apache2:
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl status apache2
確保 Apache2 正常運行,並可通過瀏覽器訪問伺服器的 IP 地址(例如:http://伺服器IP)。-l29dvgl92bgl3a43z./)
調整防火牆規則,允許 HTTP 和 HTTPS 流量:
sudo ufw allow 'Apache Full'
安裝 MariaDB:
sudo apt install mariadb-server -y
啟動並設置 MariaDB:
sudo systemctl start mariadb
sudo systemctl enable mariadb
執行安全設置向導,強化 MariaDB 安全性:
sudo mysql_secure_installation
根據提示完成設置,建議:
設定 root 密碼。
移除匿名用戶。
禁止 root 遠端登錄。
刪除測試資料庫。
驗證 MariaDB 是否正常運行:
sudo systemctl status mariadb
添加 PHP 8.1 的 PPA(Personal Package Archive):
sudo add-apt-repository ppa:ondrej/php
sudo apt update