网站复活之路

更新

#!/bin/bash

sudo apt update && sudo apt upgrade -y

安装 Nginx

#!/bin/bash

sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring -y

curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
    | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg

echo "确认包含:573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62"

# 提示用户输入
read -p "输入 'n' 或 'N' 取消,输入其他任意键继续: " confirm

# 检查用户输入
if [[ "$confirm" == "n" || "$confirm" == "N" ]]; then
    echo "操作已取消。"
    exit 1
else
    echo "继续执行操作..."
    # 在这里执行后续操作
fi

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

sudo apt update

sudo apt install nginx -y

设置防火墙

sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

sudo ufw enable

sudo ufw status

安装 MySQL

sudo apt install mysql-server -y

sudo mysql_secure_installation

安装密码生成工具

sudo apt install pwgen -y

生成强密码备用

pwgen -sB 16 1

安装 PHP

sudo apt install php8.1 php8.1-fpm php8.1-mysql php8.1-xml php8.1-mbstring php8.1-curl php8.1-zip php8.1-gd -y

安装 acme.sh

curl https://get.acme.sh | sh -s email=mail@example.com

source ~/.bashrc

申请证书

安装证书

创建网站目录

配置 Nginx

创建数据库

安装 WordPress