要实现下图这种,输入用户名/密码之后才能访问
科普几个Nginx命令
- nginx -s reload:重新加载nginx配置
- nginx -s stop:强制停止nginx
- nginx -s quit:优雅停止nginx
- nginx -t:修改配置之后【测试】配置是否正确
- nginx:默认启动nginx
一、安装htpasswd
- yum -y install httpd-tools
二、添加账号密码
- htpasswd -c /usr/local/soft/nginx/conf/pwd hello 接着输入两次密码即可
- htpasswd -c:意思是创建一个加密文件
- /usr/local/soft/nginx/conf/pwd:路径+加密文件名
- hello:用户名
- cd /usr/local/soft/nginx/sbin/
- ./nginx -t
- ./nginx -s reload