Nginx 快速开始

1. 安装

1
sudo apt install nginx

2. 配置

1
sudo vim /etc/nginx/sites-available/default
  1. 找到 server 下的 root 改为 html 所在位置
  2. 找到 server 下的 server_name 改为 example.com www.example.com

3. 测试并重启

1
2
sudo nginx -t
sudo systemctl restart nginx

另: SSL 证书

1
2
3
4
5
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx

# 测试自动续签是否可行 (模拟执行)
sudo certbot renew --dry-run