编辑nginx配置文件

location / {
auth_basic "yanzheng";
auth_basic_user_file /etc/nginx/htpasswd; (生成文件的路径)
}

安装 htpasswd 工具

yum -y install httpd-tools  

在 /etc目录下创建nginx

mkdir /etc/nginx/

创建文件

nano /etc/nginx/htpasswd

在原文件的基础上新增一个账户

htpasswd -b htpasswd root 123
            (文件名)  (用户名) (密码)

新建文件 路径也在/etc/nginx

htpasswd -bc nmsl root 123
            (文件名)  (用户名) (密码)

删除用户

cd /etc/nginx/htpasswd

htpasswd -D htpasswd root
            (文件)   (用户名)

参考链接 https://www.cnblogs.com/cainiaoliu/articles/6406623.html

最后修改日期: 2020年6月22日