天天看點

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

繼續閱讀