ngixn配置:

在虚拟主机中添加机配置文件;
   #auth_passwd
   location / {
   auth_basic "please input you password";
   auth_basic_user_file /usr/local/nginx-1.2.1/conf/auth_passwd;
   }
   #-----------------------------------------------------、

密码格式:
   auth_basic_user_file文件格式:
   [user]:[加密之后的密码字符串]
   例:zjadmin:she3J88KUq1.2

#密码生成使用pw.pl脚本

_____________________________________________________

autoindex on;//自动显示目录
autoindex_exact_size off;//人性化方式显示文件大小否则以byte显示
autoindex_localtime on;//按服务器时间显示,否则以gmt时间显示


在nginx.conf 主配置文件里添加只需要添加这两行即可;
   auth_basic "please input you password";
   auth_basic_user_file /usr/local/nginx-1.2.1/conf/auth_passwd;