天天看点

LNMP_用户认证

 用户认证

首先需要安装apache,可以使用yum install httpd 安装

生成密码文件,创建用户

<a href="http://s4.51cto.com/wyfs02/M01/85/34/wKiom1eckh3QDkR_AAANSorbnpw057.png" target="_blank"></a>

<a href="http://s4.51cto.com/wyfs02/M01/85/34/wKioL1eckh7QXtXZAAAiM37PuZc839.png" target="_blank"></a>

htpasswd -c /usr/local/nginx/conf/htpasswd  test // 添加test用户,第一次添加时需要加-c参数,第二次添加时不需要-c参数

在nginx的配置文件中添加   vi /usr/local/nginx/conf/vhosts/jzq.conf

location  / {

                      root /data/www/uc_server;

                      auth_basic              "Auth";

                      auth_basic_user_file   /usr/local/nginx/conf/htpasswd;

            }

<a href="http://s1.51cto.com/wyfs02/M02/85/34/wKiom1eclGShGG42AABB8JIPxWQ969.png" target="_blank"></a>

 /usr/local/nginx/sbin/nginx -t

 /usr/local/nginx/sbin/nginx -s reload

验证:

<a href="http://s3.51cto.com/wyfs02/M00/85/34/wKiom1eclM3ggDEvAABvoUzekq4795.png" target="_blank"></a>

本文转自 15816815732 51CTO博客,原文链接:http://blog.51cto.com/68686789/1832154

继续阅读