主要工作:购买云服务器、安全组放行端口、创建普通用户 study、配置SSH密钥登录、禁用root密码登录。
关键命令:
# 创建普通用户
sudo useradd study
sudo passwd study
# 将study加入sudo权限组
sudo usermod -aG wheel study
# 本地生成ssh密钥对
ssh-keygen
# 把公钥上传到服务器
ssh-copy-id study@服务器公网IP
# 修改sshd配置禁止root密码登录
sudo vi /etc/ssh/sshd_config
sudo systemctl restart sshd
/etc/ssh/sshd_config设置PermitRootLogin no,修改后必须重启sshd服务配置才生效。
主要工作:安装Nginx,编写虚拟主机server配置,部署静态网页,排查403权限错误,理解Nginx主进程、worker工作进程。
关键命令:
# 安装nginx
sudo dnf install nginx
sudo systemctl enable --now nginx
# 检查配置语法
sudo nginx -t
# 重载配置(不中断访问)
sudo systemctl reload nginx
# 查看nginx进程
ps -ef | grep [n]ginx
# 查看目录权限
ls -ld /var/www/mysite
主要工作:安装certbot,使用webroot方式申请SSL证书;配置80端口301跳转HTTPS;配置自动证书续期。
关键命令:
# 安装certbot
sudo dnf install certbot
# 证书申请演练
sudo certbot certonly --webroot -w /var/www/mysite -d
pengyingtao.fun --dry-run
# 正式申请证书
sudo certbot certonly --webroot -w /var/www/mysite -d
pengyingtao.fun
# 模拟续期测试
sudo certbot renew --dry-run
# 查看本机全部证书
sudo certbot certificates
/.well-known/acme-challenge/对应的root目录写错,验证程序无法访问验证文件。